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
5 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.

01local debounce = false
02mpservice = game:GetService("MarketplaceService")
03passid = 1234567 -- not the real id
04rbcarpet = game.Lighting:WaitForChild("RainbowMagicCarpet")
05 
06function onTouch(hit)
07if not debounce then
08debounce = true
09local pla=game:GetService("Players"):GetPlayerFromCharacter(hit.Parent)
10if pla then
11if mpservice:UserOwnsGamePassAsync(pla.UserId, passid) then
12rbcarpet:Clone().Parent = pla.Backpack
13print("they own gamepass and get tool")
14else
15mpservice:PromptGamePassPurchase(pla, passid)
View all 32 lines...

1 answer

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

Add this right after local pla

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

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

Ad

Answer this question