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
Edited 6 years ago

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

Log in to vote
0
Answered by
TrippyV 314 Donator Moderation Voter
6 years ago

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.

0
Also, don't use Lighting for storage. Use ReplicatedStorage when accessing from LocalScripts and ServerStorage when accessing from Server Scripts. Azarth 3141 — 6y
0
I appreciate the help I was so confused on my it wouldn't work. Thank you so much! TheForgottenTale 23 — 6y
Ad

Answer this question