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

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

Asked by 4 years ago

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

Log in to vote
1
Answered by
JesseSong 3916 Moderation Voter Community Moderator
4 years ago
Edited 4 years ago

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)
0
The second one worked, thanks. SpeedyTV_1 88 — 4y
0
Beat me to it lol xInfinityBear 1777 — 4y
0
Accept my answer please JesseSong 3916 — 4y
Ad
Log in to vote
0
Answered by 4 years ago

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)

Answer this question