Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 5 years ago

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?

1
if v == "stinkyest11" then break end. But I recommend to use UserId as the names can change User#19524 175 — 5y
0
none of us will have enough robux for that mate :) stinkyest11 78 — 5y

1 answer

Log in to vote
0
Answered by
Rare_tendo 3000 Moderation Voter Community Moderator
5 years ago
Edited 5 years ago

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)
Ad

Answer this question