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)
✓ ANSWER ACCEPTED
What's wrong with my script?
1 answer
✓ Accepted answer
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)
1 comment
0
Thank you.
This discussion is preserved as it was. New answers, comments, and votes are closed.

2 comments
Why down vote you idiots.
Probably because you didn't post an explanation. https://scriptinghelpers.org/help/how-post-good-questions-answers