How do I check if something is from a table?

lets say i wanna make an admin script

local usernames = {
	"YouthfulPat501",
"Roblox,
"Builderman
}

game.Players.PlayerAdded:connect(function(player)
	player.CharacterAdded:Connect(function(character)
		if player.Name == usernames[1] then
			print("eligible for admin")
		end
	end)
end)

if i write

if player.Name == usernames[1] then

it will only check if the player’s username is the first index in the table
how do i automate this and make it check through all the indexes from the table so i wouldn’t have to write
if player.Name == usernames[1] or player.Name == usernames[2] and so on

If I remember well you can do if table.find(usernames, player.Name) then

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.