So I am making a team changing script and I want to so that when I join it throws me on a team called Teacher. I already know how to do that but I was wondering if
if Players.conman0552
would work. I have tried this many times and have even tried to just get the character. Please help me.
You can use tables for detecting multiple users.
Example
admins = { ["BluDev"] = true; ["Friend"] = true } game.Players.PlayerAdded:connect(function(player) if admins[player.Name] then --put any code you want here end end)
Table Help:
admins = { ["NAME HERE"] = true; ["NAME HERE"] = true }
The list can go on however long you want.
Example Script:
admins = { ["BluDev"] = true; ["Friend"] = true; ["Player"] = true; } game.Players.PlayerAdded:connect(function(player) player.CharacterAdded:connect(function(char) if admins[player.Name] then print(player.Name.." is an admin of this game") char:WaitForChild("Humanoid").MaxHealth = 500 char:WaitForChild("Humanoid").Health = 500 end end) end)
What wfvj014 posted would work, however I prefer using "UserId" as an identifier. To do so, use the code below:
game.Players.PlayerAdded:connect(function(player) if player.UserId == 81482246 then player.TeamColor = BrickColor.new("White") -- Color of team. end end)
Happy scripting!
Well, you should make sure to add this to a player added function,
game.Players.PlayerAdded:connect(function(player) if player.Name == "WillyBottom" then ---Stuff here end end)
Good luck!
maybe this:
if Players.conman0552 = true then