✓ Accepted answer
First, please learn to use the code block, it's very useful and would tidy your code.
It would look like this:
local productId = 0
local player = game.Players.LocalPlayer
local name = "Gold"
local reward = 500
game:GetService("MarketplaceService").PromptGamePassPurchaseFinished:connect(function(p, gamepass, pur)
if gamepass==productId then
if game:GetService("Players"):FindFirstChild(p.Name) then
game:GetService("Players"):WaitForChild(p.Name).leaderstats:WaitForChild(name).Value = game:GetService("Players"):WaitForChild(p.Name).leaderstats:WaitForChild(name).Value + reward
end
end
end)
script.Parent.MouseButton1Click:connect(function()
end)
Also, the problem here is that productId is 0.
When it says "change to your Gamepass product ID" it means that you should change the 0 to the id of the gamepass.
Try learning some basic Lua first, and you'll understand what I mean clearly.
So yeah, all you have to do is change the 0 to your gamepass's ID.
3 comments
Remember that connect and Game are deprecated aswell.
I changed 0 to the ID but it won't change the leaderstats
Oh, I edited. Check my new answer.