This is not changing the team. Not sure how to fix it
player.CharacterAdded:Connect(function(char)
char.Humanoid.Died:Connect(function()
player.Team = game.Teams.Spectators
This is not changing the team. Not sure how to fix it
player.CharacterAdded:Connect(function(char)
char.Humanoid.Died:Connect(function()
player.Team = game.Teams.Spectators
Maybe it is a delay problem, put a wait first like wait(1) to see. Or if I am not wrong, you can’t switch teams using the team instance, maybe you can only do it with the team colour
Is this script running in a server script or local script?
Team changes can only be done from the server and that may be causing your problem.
This is located in serverscriptservice
Hmm, here try this script it seems to be working for me.
local SpecTeam = game.Teams:WaitForChild("Spectators")
game.Players.PlayerAdded:Connect(function(Player)
Player.CharacterAdded:Connect(function(Character)
Character.Humanoid.Died:Connect(function() -- Detecting death
Player.Team = SpecTeam -- Setting the team to Spectators on death
end)
end)
end)
game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(char)
char.Humanoid.Died:Connect(function()
player.Team = game.Teams.Spectators
end)
end)
end)
Is your code like this?
I’m not sure if roblox automatically disconnects those types of RBXSignals but I would really suggest disconnecting all connections you had made inside the CharacterAdded fucntion just to be on the safe side.
Yes, all connections are destroyed if the instance it was connected to is destroyed, still a good thing to practice though!