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

White list script kicks everyone join the game. How to fix?

Asked by 4 years ago
Edited 4 years ago

I am making a "Only Allowed Players" script but it will kick everyone join the game include the allowed players.

local allowed = {545158376,0} -- Allowed players

game.Players.PlayerAdded:Connect(function(player)
    if player.UserId~= allowed then
        player:Kick("Tester only!")
    end
end)

1 answer

Log in to vote
0
Answered by
raid6n 2196 Moderation Voter Community Moderator
4 years ago
Edited 4 years ago

Edted code:

local allowed = {545158376, 0} -- Allowed players ids

game.Players.PlayerAdded:Connect(
    function(player)
        for i, v in ipairs(allowed) do
            if player.UserId ~= v then
                player:Kick("Testers only.")
            end
        end
    end
)

What you did wrong, you did player.Name instead of the Player.UserId, and you didn't loop through all the allowed ids.

Ad

Answer this question