Can anyone tell me why this RemoteEvent script won't change the Player's team, but yet it print's the final thing? I can't really explain any better I'm tired. ._.

Script:

game.ReplicatedStorage.Events.RemoteEvent.OnServerEvent:connect(function()
	local Players = game.Players:GetPlayers()
	for i = 1,#Players do
		wait(0.1)
		if not Players[i].TeamColor == game.Teams.TestTeam.TeamColor then
			Players[i].TeamColor = game.Teams.TestTeam2.TeamColor
			Players[i]:LoadCharacter()
		end
	end
	print("Completed.")
end)

Any help appreciated.

3 comments

0

It looks like it's because of the not in the if statement. If the player is not on TestTeam then do not try to move them to TestTeam2 is how the script is interpreting it.

0

@M39 That's how it's supposed to work. Example: You have a Trainee and Trainer team, and you don't want people on the Trainer team to be changed.

0

Well, that would have been nice to know with an explanation. ^.^ Try having multiple prints through the function and see where it might be skipping or going wrong. As far as I can see, there are no problems with your script.