Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Find Specific players?

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.

2 comments

0

So considering I answered your question first and my script works just fine, you should except my answer (: or at least like it (: please? I like points. The other guy basically copied my answer anyway :P

0

Ya but yours is inefficient and such.

4 answers

✓ Accepted answer

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!

1 comment

0

Lol, one up me will you.

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

1 comment

0

This wouldn't work. You need a function to check if the player is the person. You would also want to use find first child and == two equals :P

This discussion is preserved as it was. New answers, comments, and votes are closed.