local localp = game.Players.LocalPlayer local CDName = {"JackPlaysRBYT","Pupp_err","Giptoid","ThePersonThatWorks","tictac67"} function FP() for i,v in pairs(CDName) do if localp.Name ~= v and localp.TeamColor ~= game.Teams["Foundation Personnel"].TeamColor then game.Workspace.TeamChangeFE.teamchange:FireServer(game.Teams["Foundation Personnel"].TeamColor) end end end script.Parent["SCP"].MouseButton1Click:connect(FP)
It wont go through the whole array I think
It is because that it goes through the whole array that you get put on the team, because the first index of the array is not your name, the if statement will be true and it will FireServer, and it will fire it 4 times as there is 5 indexes in the array and 4 of them are not yours
Just add a boolean that becomes true if it found your name in the array, and after the for loop ended, it checks if the boolean is true or not, if not then it will change the team.
local localp = game.Players.LocalPlayer local CDName = {"JackPlaysRBYT","Pupp_err","Giptoid","ThePersonThatWorks","tictac67"} local InTheList = false function FP() for i,v in pairs(CDName) do if localp.Name == v and localp.TeamColor ~= game.Teams["Foundation Personnel"].TeamColor then InTheList = true break end end if not InTheList then game.Workspace.TeamChangeFE.teamchange:FireServer(game.Teams["Foundation Personnel"].TeamColor) end end script.Parent.MouseButton1Click:connect(FP)
Personally for me i would do the checking at the server side, as it is more secure.