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

How To Make A Script Were Specific Users Unkickable?

Hello, Can Anyone Help On My Script. Im Trying To Make Specific Users Unkickable. Heres My Script (Script Is On ServerScriptService)

For More Information: Im Making A Admin Panel With A Kick Script.. But I Want Admins To Be Unable To Be Kicked.

game.ReplicatedStorage.KickPlayer.OnServerEvent:connect(function(player, playerToKick, reason)
    local Info = {}

    Info.Whitelist = {
        ["test"] = true,
        ["test2"] = true
    }

    function Info:AdminP(player)
        if Info.Whitelist[player.name]  then
            return true
        else
            return false
        end
    end

    local Player = game.Players.LocalPlayer

    if Info:AdminP(Player) then
        print(playerToKick.." Is A Admin Player, You Cannot Kick.")
    else
        game.Players:FindFirstChild(playerToKick):Kick("Kicked! Reason: "..reason.." - Kicked By: "..player.Name)
    end
end)

1 answer

✓ Accepted answer

Alright, this is on the right track but you should avoid using ["index"] = true in this case as it's not very necessary.

Instead, let's do this:

local Whitelist = {12345} -- Going by UserId is way more secure.

game:GetService("ReplicatedStorage").KickPlayer.OnServerEvent:Connect(function(plr,reason)
    if table.find(Whitelist,plr.UserId) then
        return
    else
        plr:Kick(reason)
    end
end)

1 comment

1

It's not "more secure", it's just more efficient; the UserId is a statically unique identifier.

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