Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

Developer Products Help :)

Asked by 10 years ago

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

Log in to vote
0
Answered by
User#2 0
10 years ago

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.

Ad
Log in to vote
0
Answered by 10 years ago

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.

Answer this question