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

How To Make A Script Were Specific Users Unkickable?

Asked by 4 years ago
Edited 4 years ago

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

Log in to vote
1
Answered by 4 years ago

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
It's not "more secure", it's just more efficient; the UserId is a statically unique identifier. Ziffixture 6913 — 4y
Ad

Answer this question