I'm trying to check if a player exists in game.players with their username, how would I go about doing this?
✓ ANSWER ACCEPTED
How do I check if a player is in game.players by username?
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.

2 comments
if game.Players:FindFirstChild(USERNAME) then
A better way of doing it is by looping and checking if a player is in a table.