Backpack is not a valid member of player

local player = game.Players.LocalPlayer

print(player.Parent.Name)

local FirstAidKit = game.ReplicatedStorage["First Aid Kit"]

local Doc = game.Teams.Doctors

print("a")

if player.Team == Doc then
	print("B")
	FirstAidKit:Clone().Parent = player.Backpack
end

This code is supposed to give the player a kit if the player is in team doc but it’s saying that backpack is not a valid member of player.

I have success with player:FindFirstChildOfClass(“Backpack”).

2 Likes

You should wait for the player to load.
add an WaitForChild

local player = game.Players.LocalPlayer

print(player.Parent.Name)

local FirstAidKit = game.ReplicatedStorage["First Aid Kit"]

local Doc = game.Teams.Doctors

print("a")

if player.Team == Doc then
	print("B")
	FirstAidKit:Clone().Parent = player:WaitForChild("Backpack")
end
1 Like

Adding to that its seem this is a local script.

And you should make it ServerSide:

game.Players.PlayerAdded:Connect(function(Player)
	Player.CharacterAdded:Connect(function(Char)
		if Player.Team == game.Teams.Doctors then
			game.ReplicatedStorage["First Aid Kit"]:Clone().Parent = Player.Backpack
		end
	end)
end)
3 Likes