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

Backpack is not a valid member of Player???

So this is my gamepass script for a player to receive an "Exceed" so they can fly around the map. Apparently it pops up with an error "Backpack is not a valid member of Player" does anyone know why?

local passId = 000000000
local Tools = {"Exceed"}
local GamePassService = game:GetService("GamePassService")

game.Players.PlayerAdded:Connect(function(Player)
	repeat wait() until Player.Backpack
	repeat wait() until Player.StarterGear
	if GamePassService:PlayerHasPass(Player, passId) then
		for i = 1, #Tools do
			game.Lighting.Tools:FindFirstChild(Tools[i]):Clone().Parent = Player.Backpack
			game.Lighting.Tools:FindFirstChild(Tools[i]):Clone().Parent = Player.StarterGear
		end
	end
end)

1 answer

✓ Accepted answer

Try this:

local passId = 00000000
local Tools = {"Exceed"}
local GamePassService = game:GetService("GamePassService")

game.Players.PlayerAdded:Connect(function(Player)
    local Backpack = Player:WaitForChild("Backpack")
    local StarterGear = Player:WaitForChild("StarterGear")
    if GamePassService:PlayerHasPass(Player, passId) then
        for i,v in pairs(Tools) do
	    game.Lighting.Tools:FindFirstChild(v):Clone().Parent = Backpack
            game.Lighting.Tools:FindFirstChild(v):Clone().Parent = StarterGear
        end
    end
end)

The only changes I made was using the WaitForChild function instead of the repeat loop.

If you have any other problems, be sure to comment on this answer so we can work it out.

2 comments

0

Also, don't use Lighting for storage. Use ReplicatedStorage when accessing from LocalScripts and ServerStorage when accessing from Server Scripts.

0

I appreciate the help I was so confused on my it wouldn't work. Thank you so much!

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