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

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

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

✓ Accepted answer

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.

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