Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Developer Products Help :)

Im testing the new Developer Products feature in roblox, Im a basic scripter i cant make big scripts. I need help with this one :

local buyButton = game.Workspace.StarterGui.ShopMain.MoneyButton
local productId = 19232057

buyButton.MouseButton1Click:connect(function()
	game:GetService("MarketplaceService"):PromptProductPurchase(game.Players.LocalPlayer, productId)
end)

buyButton.MouseButton1Click:connect(function()
local stats = user:findFirstChild("leaderstats")
if stats ~= nil then
local cash = stats:findFirstChild("Money")
cash.Value  = cash.Value +100
end

Im trying to make a gui button that gives you 100+ Money. The Gui button its ok but i dont know if the script will work correctly.

the productId is 19232057 and the Leaderstat is "Money"

Please help :D

2 answers

✓ Accepted answer

There was one error I found, overall; you forgot to end your function for the MouseButton1Click event.

But your script won't work how you expect.

buyButton.MouseButton1Click:connect(function()
local stats = user:findFirstChild("leaderstats")
if stats ~= nil then
local cash = stats:findFirstChild("Money")
cash.Value  = cash.Value +100
end

This is your problem area. This says "When the player clicks this button give them 100 money without checking anything".

To fix this you can use the PromptProductPurchaseFinished event.

The error that I spotted was that you put:

local buyButton = game.Workspace.StarterGui.ShopMain.MoneyButton

When it should be:

local buyButton = game.StarterGui.ShopMain.MoneyButton

Next time, remember that StarterGui is **NOT **in Workspace it is by itself in game.

This discussion is preserved as it was. New answers, comments, and votes are closed.