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

How do I check if a player is in game.players by username?

I'm trying to check if a player exists in game.players with their username, how would I go about doing this?

2 comments

0

if game.Players:FindFirstChild(USERNAME) then

0

A better way of doing it is by looping and checking if a player is in a table.

1 answer

✓ Accepted answer

Make a table of the list of people you want then loop through The below code should work.

game.Players.PlayerAdded:Connect(function(player)
local tab = { "Player1"," Player2"} -- list of people you want
for i,v in pairs(tab) do
if player.Name == v then
print ("player is in game")
end
end
end)

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