Below is an example of a Roblox Studio setup that creates a simple GUI with two “troll” buttons. Each button, when clicked, will prompt the player to purchase a Developer Product (which costs Robux). When the purchase goes through, a server‐side script activates a “troll effect” on the player (for example, changing their character’s colors or temporarily increasing their walk speed). Note:
You must first create your Developer Products in the Roblox Developer Console and update the placeholder product IDs in the scripts below.
Use these examples as a starting point and adjust the “troll” effects as you wish.
All in‑game transactions (purchases) must use Roblox’s official systems (Developer Products or Game Passes) to comply with Roblox rules.
There are two parts to this implementation:
1. The GUI (LocalScript)
Place this LocalScript under a ScreenGui (or in StarterPlayer → StarterPlayerScripts if you create the GUI programmatically). This script creates a GUI with two buttons and attaches an event for each button that calls MarketplaceService to prompt the purchase.
lua
-- LocalScript: Place this under a ScreenGui in StarterGui or create it dynamically.
local Players = game:GetService("Players")
local MarketplaceService = game:GetService("MarketplaceService")
local localPlayer = Players.LocalPlayer
-- If you don’t already have a ScreenGui in PlayerGui, you can create one programmatically:
local screenGui = Instance.new("ScreenGui")
screenGui.Name = "TrollsGui"
screenGui.Parent = localPlayer:WaitForChild("PlayerGui")
-- Create Troll Button 1
local trollButton1 = Instance.new("TextButton")
trollButton1.Name = "TrollButton1"
trollButton1.Size = UDim2.new(0, 200, 0, 50)
trollButton1.Position = UDim2.new(0.1, 0, 0.1, 0)
trollButton1.Text = "Activate Troll Effect 1"
trollButton1.Parent = screenGui
-- Create Troll Button 2
local trollButton2 = Instance.new("TextButton")
trollButton2.Name = "TrollButton2"
trollButton2.Size = UDim2.new(0, 200, 0, 50)
trollButton2.Position = UDim2.new(0.1, 0, 0.25, 0)
trollButton2.Text = "Activate Troll Effect 2"
trollButton2.Parent = screenGui
-- Replace these Developer Product IDs with your own IDs from the Developer Console.
local product1Id = 12345678 -- For Troll Effect 1 (costs a set amount of Robux)
local product2Id = 87654321 -- For Troll Effect 2 (costs a set amount of Robux)
-- When a button is clicked, prompt the purchase for the respective Developer Product.
trollButton1.MouseButton1Click:Connect(function()
MarketplaceService:PromptProductPurchase(localPlayer, product1Id)
end)
trollButton2.MouseButton1Click:Connect(function()
MarketplaceService:PromptProductPurchase(localPlayer, product2Id)
end)
2. The Purchase Processing Script (Server Script)
Place the following Script in ServerScriptService. Roblox calls this script’s ProcessReceipt function when a Developer Product is purchased. Depending on the ProductId, a “troll effect” is applied to the player.
lua
-- Script: Place this in ServerScriptService.
local MarketplaceService = game:GetService("MarketplaceService")
local Players = game:GetService("Players")
local function processReceipt(receiptInfo)
local player = Players:GetPlayerByUserId(receiptInfo.PlayerId)
if not player then
-- If the player isn’t found, try processing later.
return Enum.ProductPurchaseDecision.NotProcessedYet
end
if receiptInfo.ProductId == 12345678 then
-- Troll Effect 1: Randomly change the colors of all BaseParts in the player's character.
if player.Character then
for _, part in ipairs(player.Character:GetDescendants()) do
if part:IsA("BasePart") then
part.Color = Color3.new(math.random(), math.random(), math.random())
end
end
end
elseif receiptInfo.ProductId == 87654321 then
-- Troll Effect 2: Temporarily double the player's walk speed.
if player.Character and player.Character:FindFirstChild("Humanoid") then
local humanoid = player.Character.Humanoid
local originalWalkSpeed = humanoid.WalkSpeed
humanoid.WalkSpeed = originalWalkSpeed * 2
-- Reset the walk speed after 10 seconds.
delay(10, function()
-- Make sure the humanoid still exists.
if humanoid then
humanoid.WalkSpeed = originalWalkSpeed
end
end)
end
else
-- If the ProductId is not handled, do not process yet.
return Enum.ProductPurchaseDecision.NotProcessedYet
end
-- Return PurchaseGranted to notify Roblox that the purchase was handled.
return Enum.ProductPurchaseDecision.PurchaseGranted
end
MarketplaceService.ProcessReceipt = processReceipt
How It Works
GUI Creation:
The LocalScript automatically creates a ScreenGui (if one isn’t already present) and two TextButtons. They are positioned on the player’s screen with simple sizes and labels.
Purchase Prompt:
When a player clicks one of the buttons, the script calls MarketplaceService:PromptProductPurchase(player, productId)
which brings up the Roblox purchase prompt for that Developer Product.
Processing the Purchase:
The server-side script in ServerScriptService listens for completed purchases. When a purchase is confirmed:
For Troll Effect 1 (product ID 12345678), it iterates through all parts in the character and assigns them random colors.
For Troll Effect 2 (product ID 87654321), it doubles the player's humanoid walk speed for 10 seconds before resetting it.
Developer Products:
You must set up your Developer Products via the Roblox Developer Console and replace the placeholder product IDs with your own. Prices for Developer Products are set up outside of the script in Roblox’s monetization system.
Final Notes
Testing Purchases: You won’t be able to test real Robux transactions in Roblox Studio. Use Roblox’s published test systems or consult the Developer Hub for testing Developer Product transactions.
Customization: Feel free to modify the “troll” effects (for example, triggering funny sound effects, teleporting the player’s character, etc.) as long as they remain within Roblox’s community standards and terms of use.
This complete example should give you a working starting point for creating a GUI with troll buttons that cost Robux to activate. Enjoy experimenting and have fun developing your Roblox game!