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

Script giving more gears than needed?

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)

1 answer

✓ Accepted answer

Add this right after local pla

if pla.Backpack:FindFirstChild("RainbowMagicCarpet") == nil and pla.Character:FindFirstChild("RainbowMagicCarpet") == nil then
	-- code here
end

Basically this checks if its in their backpack and if its in their character.

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