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

Backpack is not a valid member of player?

Asked by 6 years ago

So I have this script:

local passid = 972737920
local tools = {"BlueFidgetSpinner"}
local GamePassService = Game:GetService('GamePassService')
game.Players.PlayerAdded:connect(function(player)
repeat wait(0.1) until player.Backpack  
repeat wait(0.1) until player.StarterGear
if GamePassService:PlayerHasPass(player, passid) then
for i = 1,#tools do
game.Lighting:FindFirstChild(tools[i]):Clone().Parent = player.Backpack
game.Lighting:FindFirstChild(tools[i]):Clone().Parent = player.StarterGear
end
end
end)

and for some reason, it's telling me: "Backpack is not a valid member of Player". Player does have a backpack though. So does anyone know how i could fix this?

1
you could do player:WaitForChild("Backpack") since that makes sure it exists abnotaddable 920 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago

Here is your problem. It thinks you are trying to do something with the backpack when you do

repeat wait() until player.Backpack

Instead, to use that, do

repeat wait() until player:FindFirstChild('Backpack')

A even better way to wait for a child is to do

player:WaitForChild('Backpack')

Also, you should indent your code.

0
The problem now is get no error nor do I get the item. StolenLimited 8 — 6y
0
In the output, is there a warning there may be a infinite yield? hiimgoodpack 2009 — 6y
0
Nope StolenLimited 8 — 6y
0
I'm really sorry, I just realized why I'm getting no error. Thanks so much for helping me, I got it now! StolenLimited 8 — 6y
Ad

Answer this question