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
1 | if Players.conman 0552 |
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
01 | admins = { |
02 | [ "BluDev" ] = true ; |
03 | [ "Friend" ] = true |
04 | } |
05 |
06 | game.Players.PlayerAdded:connect( function (player) |
07 | if admins [ player.Name ] then |
08 | --put any code you want here |
09 | end |
10 | end ) |
Table Help:
1 | admins = { |
2 | [ "NAME HERE" ] = true ; |
3 | [ "NAME HERE" ] = true |
4 | } |
The list can go on however long you want.
Example Script:
01 | admins = { |
02 | [ "BluDev" ] = true ; |
03 | [ "Friend" ] = true ; |
04 | [ "Player" ] = true ; |
05 | } |
06 |
07 |
08 | game.Players.PlayerAdded:connect( function (player) |
09 | player.CharacterAdded:connect( function (char) |
10 | if admins [ player.Name ] then |
11 | print (player.Name.. " is an admin of this game" ) |
12 | char:WaitForChild( "Humanoid" ).MaxHealth = 500 |
13 | char:WaitForChild( "Humanoid" ).Health = 500 |
14 | end |
15 | end ) |
16 | end ) |
What wfvj014 posted would work, however I prefer using "UserId" as an identifier. To do so, use the code below:
1 | game.Players.PlayerAdded:connect( function (player) |
2 | if player.UserId = = 81482246 then |
3 | player.TeamColor = BrickColor.new( "White" ) -- Color of team. |
4 | end |
5 | end ) |
Happy scripting!
Well, you should make sure to add this to a player added function,
1 | game.Players.PlayerAdded:connect( function (player) |
2 | if player.Name = = "WillyBottom" then |
3 | ---Stuff here |
4 | end |
5 | end ) |
Good luck!
maybe this:
if Players.conman0552 = true then