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

Script giving more gears than needed?

Asked by
OhManXDXD 445 Moderation Voter
4 years ago

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

Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

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.

Ad

Answer this question