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

My admin script is not working?(specific title)

Asked by 5 years ago
Edited 5 years ago

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

0
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). turtle2004 167 — 5y
0
:/ u know how long it took to made this script HappyTimIsHim 652 — 5y
0
you should check if the player is an admin at the beginning of the PlayerAdded. doing it everytime they chat is inefficient and unnecessary Gey4Jesus69 2705 — 5y
0
ok HappyTimIsHim 652 — 5y
View all comments (9 more)
0
THATS LOTS OF ends WideSteal321 773 — 5y
0
k HappyTimIsHim 652 — 5y
0
omg they left WideSteal321 773 — 5y
0
is that supposed to help an upvote??? HappyTimIsHim 652 — 5y
0
specific title, very specific title yes. WideSteal321 773 — 5y
0
:/ ur making my bell have notification and its just a comment >:(( HappyTimIsHim 652 — 5y
0
ok i stop WideSteal321 773 — 5y
0
If it's not, then put it in a server script, otherwise you wouldn't be allowed to kick people in a FE game. JayzYeah32 62 — 5y
0
its in serverscriptservice and its a script FE disabled HappyTimIsHim 652 — 5y

Answer this question