Team changing error

game:GetService('Players').PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(character)
		character:WaitForChild("Humanoid").Died:Connect(function()
			if player.TeamColor == BrickColor.new("Lime green") then	
				game.Players.player.Team.Team.Value = "lobby"
			end	
		end)
	end)
end)


21:40:33.807 - player is not a valid member of Players

21:40:33.808 - Stack Begin

21:40:33.808 - Script 'ServerScriptService.spawn', Line 6 -- igore this

21:40:33.808 - Stack End

What is the problem of this code? ;\

2 Likes

You would have to index the variable and do game.Players[player.Name]

Not really, he already has the player in his Parameter on Players.PlayerAdded.

Ik, but if he wanted to take that path, that’s how he would have to go about doing that.

I think this was what @DarkDanny04 was talking about… yeah, I would recommend using

game.Players[player.Name].Team.Team.Value

1 Like

Whenever I change a players team, I have a variable for it, here is a script:
You must change it like add the humanoid.Died

local Lobby = game.Teams:WaitForChild("Lobby")

game.Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(character)
		game.Players[player.Name].Team = Lobby
	end)
end)
1 Like