function onPlayerRespawned(newPlayer) if (newPlayer:IsInGroup(1144981)==true) then ----the ID of the group that will spawn Under that Team. newPlayer.TeamColor = game.Teams["Malaysian Armed Forces"].TeamColor end end function onPlayerEntered(newPlayer) newPlayer.Changed:connect(function (property) if (property == "Character") then onPlayerRespawned(newPlayer) end end) --if (_G.checkOkToBan(newPlayer.Name)) then --newPlayer:remove() --end end game.Players.PlayerAdded:connect(onPlayerEntered)
The problem is that you're trying to use the Changed
event, while you should be using the CharacterAdded
event. This event fires every time a player respawns, or every time a character is added to the player. I'm going to use anonymous functions for my example because I find them more readable and easier to use.
game.Players.PlayerAdded:connect(function(plr) plr.CharacterAdded:connect(function(chr) if plr:IsInGroup(1144981) then plr.TeamColor = game.Teams["Malaysian Armed Forces"].TeamColor end end) end)