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