I was trying to make a gui button to buy a game pass and when the game pass is bought it adds +1 to your stage. I couldn't get it to work, when you click it nothing happens. Is there something wrong with it? Can somebody help me? Here is the code:
local ITEM_ID = 244697986
local STAGE = script.Parent.Parent.Parent.Parent.leaderstats.Stage
local MarketplaceService = game:GetService("MarketplaceService")
local player = script.Parent.Parent.Parent.Parent
function onButtonClicked()
if STAGE.Value == 47 then return end
MarketplaceService:PromptPurchase(ITEM_ID)
wait(.5)
if MarketplaceService:PlayerOwnAsset(player, ITEM_ID) then
STAGE.Value = STAGE.Value +1
wait(.1)
player.Character.Humanoid.Health = 0
wait(5.2)
script.Parent.Parent:remove()
end
end
script.Parent.MouseButton1Click:connect(onButtonClicked)
Please help me fix it! :(

2 comments
Thx :D
Np : )