It would print “Not whitelisted: Afraid4life.” and “Whitelisted: Afraid4life.” my name was on the list. If i remove my name from the list it would print “not Whitelisted: Afraid4life.” like it should be.
local whitelist = {} -- removed names
game.Players.PlayerAdded:Connect(function(player)
repeat wait(2) until player
for i,whitelisted in pairs(whitelist) do
if whitelisted[player.Name] then
print("Whitelisted: "..player.Name..".")
else
print("Not whitelisted:"..player.Name..".")
end
end
Hello, so you can use the same for loop to find the person inside of the table called whitelist. You can also use table.find(), but I prefer to use a for loop.
for i, whitelisted in pairs(whitelist) do
if whitelisted == player.Name then
print(player.Name .. " is whitelisted!")
else
print(player.Name .. " is not whitelisted")
end
end
How are you adding names to the whitelist? Can you show an example? The reason I’m asking is because you’re accessing the whitelist table as a hash of the player name, but that won’t work if the whitelist is just an array of names.
Also, repeat wait(2) until player does nothing but yield your program for 2 seconds. The player object exists immediately. I’d recommend just removing that line.