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)
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)