So I was trying to make a script for a gamepass gear giver and for some reason, whenever the purchase goes through, it returns more gears than needed. I had this problem with products and now it's with gears.
local debounce = false
mpservice = game:GetService("MarketplaceService")
passid = 1234567 -- not the real id
rbcarpet = game.Lighting:WaitForChild("RainbowMagicCarpet")
function onTouch(hit)
if not debounce then
debounce = true
local pla=game:GetService("Players"):GetPlayerFromCharacter(hit.Parent)
if pla then
if mpservice:UserOwnsGamePassAsync(pla.UserId, passid) then
rbcarpet:Clone().Parent = pla.Backpack
print("they own gamepass and get tool")
else
mpservice:PromptGamePassPurchase(pla, passid)
mpservice.PromptGamePassPurchaseFinished:Connect(function(player, gamePassId, wasPurchased)
if wasPurchased then
rbcarpet:Clone().Parent = pla.Backpack
print("they bought gamepass and got tool")
else
print("they just said no lol")
end
end)
end
end
wait(3)
debounce = false
end
end
script.Parent.Touched:connect(onTouch)
