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

Whitelist For Loop kicks me out before the loop gets to my name in the table?

This is the table (changed their name just for the question as they didnt want their roblox names shown)

local Access = {"a","b","c","d","e"}

this is the for loop which kicks me before it gets to my name in the table

game.Players.PlayerAdded:Connect(function(plr)
	
	for i, AdminName in ipairs(Access) do
				
		if plr.Name ~= AdminName then
				
				plr:Kick("You're not whitelisted, mate.")
				
			else
					
				break
				
		end
	end
end)

is there a method to stop it from kicking me before the loops gets to my name?

2 comments

1

if v == "stinkyest11" then break end. But I recommend to use UserId as the names can change

0

none of us will have enough robux for that mate :)

1 answer

✓ Accepted answer

Make a variable and check if the player's name is found in the Access table. If the player's name is found in there, change the variable's value to true, else don't change it.

If the variable is true, then don't kick them, else, you'll kick them.

game.Players.PlayerAdded:Connect(function(plr)
    local found = false   

       for _, AdminName in pairs(Access) do
	     if plr.Name == AdminName then
	           found = true
	     end
       end

       if not found then
	      player:Kick("You're not whitelisted, mate.")
       end
end)

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