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

Whitelist script kicks me out of the game even when I'm on it?

I've tried to made a whitelist script. It seemed like a pretty easy task but as it showed up later, it isn't. The script kicks me even when my ID is on the script and I don't know why.

local whitelist = {
	130021889 -- SpeedyTV_1
}

game.Players.PlayerAdded:Connect(function(p)
	if p.UserId ~= whitelist then
		p:Kick("Not whitelisted")
	end
end)

2 answers

✓ Accepted answer

The error could be that your not the whitelister Basically you need to make the two conditional statements true

local Players = game:GetService("Players")
local WHITELIST = {"names"}-- Change to your preference

Players.PlayerAdded:Connect(function (player)
    if not table.find(WHITELIST, player.Name) then
        player:Kick()
    end
end)

3 comments

0

The second one worked, thanks.

0

Beat me to it lol

0

Accept my answer please

Here, this should work.

local whitelist = {

130021889 -- SpeedyTV_1

}

game.Players.PlayerAdded:Connect(function(p)
	if not table.find(whitelist, p.UserId) then
		p:Kick("You are not whitelisted.")
	end
end)

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