Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why doesn't changing a player's team work with FilteringEnabled?

Asked by 8 years ago

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.

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. M39a9am3R 3210 — 8y
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. ISellCows 2 — 8y
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. M39a9am3R 3210 — 8y

Answer this question