I'm making my own admin script and I'm not so successful.
function bancheck(plr, ban)
if ban.Value == true then
plr:Kick("You're banned")
end
end
function Admincheck(plr, Admin)
for i, Name in ipairs(Admin) do
if Name == plr then
admin = true
end
end
end
function onkill(msg, plr)
if msg:sub(1, 6) == prefix.."kill " then
local TargetPlayer = game.Players:FindFirstChild(msg:sub(7))
if TargetPlayer then
local ctr = TargetPlayer.Character or TargetPlayer.CharacterAdded:Wait()
local hum = ctr:WaitForChild("Humanoid")
hum.Health = 0
elseif msg:sub(7):lower() == "me" then
plr.Character.Humanoid.Health = 0
end
end
end
function onban(msg, plr, Admin, vip)
if msg:lower():sub(1, 5) == prefix.."ban " then
local TargetPlayer = game.Players:FindFirstChild(msg:sub(6))
if TargetPlayer then
for a, b in ipairs(Admin) do
if b == TargetPlayer.Name then
if plr.Name == vip then
if TargetPlayer == vip then
else
Banned:SetAsync(TargetPlayer.UserId, true)
TargetPlayer:Kick("You're banned")
end
end
end
end
end
end
end
function shutdown(msg)
if msg:lower():sub(1, 10) == prefix.."shutdown " then
game.Players:ClearAllChildren()
workspace:ClearAllChildren()
end
end
DS = game:GetService("DataStoreService")
Banned = DS:GetDataStore("BanList")
Admins = {"HappyTimIsHim", "vinatul", "crundee341_AltV2"}
plus = {"HappyTimIsHim"}
prefix = "!"
admin = nil
game.Players.PlayerAdded:Connect(function(plr, ban)
ban = Instance.new("BoolValue")
ban.Parent = plr
ban.Value = Banned:GetAsync(plr.UserId) or false
bancheck(plr)
Admincheck(plr, Admins)
if admin ~= nil then
if admin == false then return end
plr.Chatted:Connect(function(msg)
onkill(msg, plr)
onban(msg, plr, Admins, plus)
shutdown(msg)
end)
end
end)
why is my script not working? I'm not good with indentations. So deal with it

13 comments
You can create an admin module in the chatservice, there's a wiki tutorial for it and it's more efficient than this (I think).
:/ u know how long it took to made this script
you should check if the player is an admin at the beginning of the PlayerAdded. doing it everytime they chat is inefficient and unnecessary
ok
THATS LOTS OF ends
k
omg they left
is that supposed to help an upvote???
specific title, very specific title yes.
:/ ur making my bell have notification and its just a comment >:((
ok i stop
If it's not, then put it in a server script, otherwise you wouldn't be allowed to kick people in a FE game.
its in serverscriptservice and its a script FE disabled