#Backpack tool bug
1 messages · Page 1 of 1 (latest)
remove the elseif's and just use if
didn't work
did you get an error?
nope
screenshot new code and output window?
ok
nothing abt it shows in output
wait why are you setting .parent on the tool twice
put it in startergear only and don't :waitforchild every time. put it in a variable, set parent to it once.
in fact probably dont want the waitforchild at all
okay i try
i thought that's what that chain was doing i didn't read it very closely..
o lol
like this? still not working
this is putting many scripts in one post and everyone gets confused..
okay yeah that's the playeradded, parenting to startergear should go there
scroll in your output window
maybe its earlier
you do seem to have a lot of prints and stuff
player.StarterGear must be undefined maybe do add that waitforchild
theoretically startergear should be created before their character
alr
roblox uses waitforchild so i guess you need it https://create.roblox.com/docs/reference/engine/classes/StarterGear
I see
** You are now Level 22! **
still doesn't work tho
basically looking for that warn
but ya setting to startergear should work if roblox docs are correct
uhh
where's the warning?
you wrapped the whole thing in pcall, which suppresses errors.
oh
though if it all appears in startergear then ids are correct and it is working, just at the wrong time
backpack gets destroyed and recreated on characteradded
oh right no, i know why
it's because getgamepass are async
so you need to add it to the character and the startergear the first time
2 clones
making sure to check if the player already has the tool first
this is hella confusing for me ngl
the thread called by playeradded yields until it gets a result from marketplaceservice, which can take up to about a second. and since you have them in series, it can take several seconds for all of them to return results. even if you put them in parallel with task.spawn each, you're still not guaranteed to have a result by the time the player gets their first character, so you have to check if the player already has the tool or not from startergear when you first receive gamepass result for each one.
startergear deals with it after the first time.
or i suppose you can just do if player.Character then -- clone to backpack on the first one, in addition to cloning to startergear 
okk
that took me a bit but got there eventually 🙂
lol all good
is it like this
if player.Character then
local speedCoil = gear.SpeedCoil:Clone()
speedCoil.Parent = player.Backpack
speedCoil.Parent = player:WaitForChild("StarterGear")
end```
🥣
😭
only because you're a mod and this is simple enough, consider it a perk of the job you do here
not many get this exception
@buoyant hull 🥣 ```lua
local function HasGamepassAsync(plr:Player,passId:number)
for i=1,5 do
local can,why = pcall(MarketplaceService.UserOwnsGamePassAsync, MarketplaceService, plr, passId)
if can then return why==true end
warn("Marketplace failed to check gamepass",passId,"for",plr,"because:",why)
task.wait(i*3)
if not plr.Parent then return false end
end
return false
end
local function CheckGamepass(plr:Player,passId:number,tool:Tool)
local hasPass=HasGamepassAsync(plr,passId)
if not HasGamepassAsync or not plr.Parent then return end
local plrGear=plr:WaitForChild("StarterGear")
if plr:FindFirstChild("Backpack") then
local clone=tool:Clone()
clone.Parent=player.Backpack
end
local clone=tool:Clone()
clone.Parent=plrGear
end
local Gamepasses = {
{id=000,toolname=""};
}::{{id:number;toolname:string}}
local ToolFolder = game:GetService("ServerStorage").Gear
local function PlayerAdded(plr:Player)
for _,gamepass in Gamepasses do
local toolTemplate=ToolFolder:FindFirstChild(gamepass.toolname)
if not toolTemplate then warn("Gamepass Tool not found",gamepass.toolname) continue end
task.spawn(CheckGamepass,plr,gamepass.id,toolTemplate)
end
end```
oh damn TYSM
typo
lua local function CheckGamepass(plr:Player,passId:number,tool:Tool) local hasPass=HasGamepassAsync(plr,passId) if not HasGamepassAsync or not plr.Parent then return end i wrote it in notepad, fixed the copypaste
the condition checks if not function, instead of if not hasPass woops
found a little mistake in line 3 which should be local can,why=pcall(MarketplaceService.UserOwnsGamePassAsync,MarketplaceService,plr.UserId,passId)
but apart from that all is good TY
that is one line, the local on the line before. the actual mistake in there is it has plr instead of plr.userid 
yess
what i meant
being a mod sure is great
player.characteradded:connect()
** You are now Level 3! **