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

How can I fix my admin script?

Asked by 10 years ago

I bet there's loads of errors there for you. I copied the first part from the ROBLOX wiki, and went on. But there's some issues with the commands. The issues: /m command doesn't work. Message doesn't show up. /h command doesn't work either. Hint doesn't show up either. Code:

--[[
    Hi everyone, welcome to Keanu73's Admin v0.0.3.
    This admin is beta, so you might expect bugs.
    New features from v0.0.1:
    Added commands (alot)
    Added a admin join (you know, don't you?)
    New features + fixes from v0.0.2:
    Fixed the whole script (it was broken, really)
    Figured out some stuff
    Fixed the admin join message.
    New features + fixes from v.0.0.3:
    Added aliases for like Keanu73 is kea
    FINALLY FIXED THE ADMIN JOIN (maybe or not?)
    Added new commands
    Fixed freeze command
    Added a new tp command (oooh :D)
    Well that's all for these news. Goodbai <3
--]]

-- Put your name and your friend's names here too :P
local isAdmin = {"Keanu73", "marioadam98", "marioadamDad98", "septicshock", "Player1"}
-- Leave the rest of the stuff. You might break the admin script.
local target
for _,player in pairs(game.Players:GetPlayers()) do
        if string.sub(player.Name,1,#name) == name then
                target = v
        end
end
function findPlayer(name)
    for _, player in ipairs(game.Players:GetPlayers()) do
        if player.Name:lower() == name:lower() then
            return player
        end
    end
end

function onPlayerEntered() -- If an admin joined...
    game.Players.PlayerAdded:connect(function(plr) for _,v in pairs(isAdmin) do if v == plr.Name then print('isadmin') end end end)
    local Message = Instance.new("Message",game.Workspace)
    Message.Text = "An admin of Keanu73's Admin has joined!" -- Alert everyone that an admin joined.
    wait(10)
    Message:Destroy()
end

function onChatted(message, player)
    if message:sub(1, 5) == "/kill" and isAdmin[player.Name] then
        victim = findPlayer(message:sub(7))
        if victim and victim.Character then
            victim.Character:BreakJoints()
        end
    end
-- Remove this block ONLY if you don't have a door. And remove the block below too. Remove nothing else except those two blocks I said.
-- NOTE: If you do have a door, rename it to "Door" without quotes, and it should work.
    if message:sub(1, 5) == "/open" and isAdmin[player.Name] then
        local Door = game.Workspace.Door
        Door.Size = Vector3.new(8.8, 5, 2)
        local Message = Instance.new("Message",game.Workspace)
        Message.Text = "Opening door. You can go in :D"
        wait(5)
        Message:Destroy()

    end

if message:sub(1, 6) == "/close" and isAdmin[player.Name] then
        local Door = game.Workspace.Door
        Door.Size = Vector3.new(8.8, 19, 2)
        local Message = Instance.new("Message",game.Workspace)
        Message.Text = "Closing door. You can't go in D:"
        wait(5)
        Message:Destroy()
    end

if message:sub(1, 6) == "/admin" and isAdmin[player.Name] then
        victim = findPlayer(message:sub(8)) -- We'll define the player we want to have admin..
        table.insert(isAdmin, victim) -- Add them to the admin table
        local Message = Instance.new("Message",victim.PlayerGui) -- Not sure this works. :/
        Message.Text = "You are an admin of Keanu73's admin!"
        wait(10)
        Message:Destroy()
    end

if message:sub(1, 5) == "/cmds" and isAdmin[player.Name] then
        local Message = Instance.new("Message",game.Workspace)
        Message.Text = "Commands: /cmds, /admin, /open, /close, /kill."
        wait(20)
        Message:Destroy()
    end

if message:sub(1, 7) == "/freeze" and isAdmin[player.Name] then
        victim = findPlayer(message:sub(9)) -- define the player we want to freeze
        if victim and victim.Character then
        victim.Character.Torso.Anchored = true
        victim.Character["Right Leg"].Anchored = true
        victim.Character["Left Leg"].Anchored = true
        victim.Character["Left Arm"].Anchored = true
        victim.Character["Right Arm"].Anchored = true
        victim.Character.Head.Anchored = true -- Freeze the WHOLE character by anchoring ALL of it's parts.
        end
    end

if message:sub(1, 9) == "/unfreeze" and isAdmin[player.Name] then
        victim = findPlayer(message:sub(11)) -- define the player we want to unfreeze
        if victim and victim.Character then
        victim.Character.Torso.Anchored = false
        victim.Character["Right Leg"].Anchored = false
        victim.Character["Left Leg"].Anchored = false
        victim.Character["Right Arm"].Anchored = false
        victim.Character["Left Arm"].Anchored = false
        victim.Character.Head.Anchored = false
        end
    end


if message:sub(1, 5) == "/mute" and isAdmin[player.Name] then
        victim = findPlayer(message:sub(7)) -- define the player we want to mute their chat.
        game.Workspace.MuteEvent.OnClientInvoke:connect(function() game:GetService("StarterGui"):SetCoreGuiEnabled(Enum.CoreGuiType.Chat, false) end) -- epik hack
        game.Workspace.MuteEvent:FireClient(victim) -- Fire the remotevent on the player which mutes it.
    end



if message:sub(1, 7) == "/unmute" and isAdmin[player.Name] then
        victim = findPlayer(message:sub(9)) -- Define the player.
        game.Workspace.MuteEvent.OnClientInvoke:connect(function() game:GetService("StarterGui"):SetCoreGuiEnabled(Enum.CoreGuiType.Chat, true) end) -- Epic hack, again.
        game.Workspace.MuteEvent:FireClient(victim) -- Fire the event on to enable the chat.
end

if message:sub(1, 2) == "/m" and isAdmin[player.Name] then
    local Message = Instance.new("Message",game.Workspace) -- Add a new message to the workspace
    Message.Text = string.sub(msg,4) -- Get the user's text of the message he wanted
    game:GetService("Debris"):AddItem(Message, 10) -- Remove it after 10 seconds.
end

if message:sub(1, 2) == "/h" and isAdmin[player.Name] then
    local Hint = Instance.new("Hint",game.Workspace) -- Same as /m command.
    Hint.Text = string.sub(msg,4)
    game:GetService("Debris"):AddItem(Hint, 10)
end

if message:sub(1, 5) == "/heal" and isAdmin[player.Name] then
    victim = findPlayer(message:sub(7)) -- Define the player we want to heal
    if victim and victim.Character then
        victim.Character.Humanoid.Health = 100 -- Heal the player.
    end
end

if message:sub(1, 7) == "/damage" and isAdmin[player.Name] then
    victim = findPlayer(message:sub(9)) -- Define the player.
    if victim and victim.Character then
        local damage = tonumber(string.match(message, '%d+$')) -- The number of the damage the player specified.
        if damage ~= nil then -- If the damage doesn't exist then...
            victim.Character.Humanoid:TakeDamage(damage) -- Damage the player the number the user specifed.
                end

if message:sub(1, 3) == "/tp" and isAdmin[player.Name] then
    victim = findPlayer(message:sub(5))
    player = game.Players.LocalPlayer
    player.Character.Humanoid:MoveTo(victim.Character.Torso.Position, victim.Character.Torso)
end


         end

     end

  end

game.Players.PlayerAdded:connect(function(player)
    player.Chatted:connect(function(message) onChatted(message, player) end)
end)

2
We're not just going to go through your entire script and fix every problem. Give us something specific to look at and help you with, and we will do our best. NoahWillCode 370 — 10y
0
Well there's a problem with the /m and /h command. The hint and message.. just doesn't show up. :/ User#35 0 — 10y
0
Okay...How about make that an entirely new question? This one is just horrible. NoahWillCode 370 — 10y
0
Lol I just edited it. User#35 0 — 10y
View all comments (5 more)
0
Do any of the other commands work? NoahWillCode 370 — 10y
0
Well.. Freeze and kill command does work. Not sure about the /admin command. Not sure about /cmds either. I'ma test. User#35 0 — 10y
0
Are there any errors (red text)? NoahWillCode 370 — 10y
0
Nope. But in the developer console (runtime errors), yes. User#35 0 — 10y
0
And please stop taking my rep q.q User#35 0 — 10y

Answer this question