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

Commands are not working, help me?

Asked by 9 years ago

So this is a commands script. What this does is when I say ";resetplace" or ";reset place" it does not reset the model named "World"

StartClone = game.Workspace.World:clone() --World is the name of the model
Prefix = ";"
local Admins = {"MarcelIa","PreyStar"}


function checkAuthority(name)
    for a,v in pairs(Admins) do --For every Admin in the table
        if v == name then --If the name matches a name in the table
            return true
        end
    end
    return false --It will only get to this point if it hasn't returned true already.
end


game.Players.PlayerAdded:connect(function(Plr)
    Plr.Chatted:connect(function(Msg)
        print(Plr.Name.." Said: ".. Msg)
        if Msg:sub(1, 1) == Prefix then
            Msg = Msg:lower()
            local MsgS = Msg:sub(2)
            print(MsgS)
            if (MsgS == "resetplace" or MsgS == "reset place") and checkAuthority(Plr.Name) then
                game.Workspace.World:remove()
                StartClone.Parent = game.Workspace
                StartClone = game.Workspace.World:clone()
            elseif MsgS == "settings" then
                Plr.PlayerGui.Tools.Settings.Visible = true
            elseif MsgS == "cmds" or MsgS == "commands" then
                Plr.PlayerGui["CommandGui's"].Gui.KeyCharacter.Text = "Prefix - "..Prefix
                Plr.PlayerGui["CommandGui's"].Gui.Visible = true
            end
        end
    end)
end)
0
This looks right. Any output? I do have an efficiency tip though. Check if they're an admin as soon as they join. That way if they're not an admin, the chatted even won't even fire. Perci1 4988 — 9y
0
I'm not sure if there was any output. This is an script my friend gave me for my game, it wasn't working so he said to come here. I don't script myself, and I'm not sure what to do. MarceIla 10 — 9y

1 answer

Log in to vote
0
Answered by 9 years ago
StartClone = game.Workspace.World:clone() --World is the name of the model
Prefix = ";"
local Admins = {"MarceIla","PreyStar"} -- all you did wrong is write her name. It's il not li


function checkAuthority(name)
    for a,v in pairs(Admins) do --For every Admin in the table
        if v == name then --If the name matches a name in the table
            return true
        end
    end
    return false --It will only get to this point if it hasn't returned true already.
end


game.Players.PlayerAdded:connect(function(Plr)
    Plr.Chatted:connect(function(Msg)
        print(Plr.Name.." Said: ".. Msg)
        if Msg:sub(1, 1) == Prefix then
            Msg = Msg:lower()
            local MsgS = Msg:sub(2)
            print(MsgS)
            if (MsgS == "resetplace" or MsgS == "reset place") and checkAuthority(Plr.Name) then
                game.Workspace.World:remove()
                StartClone.Parent = game.Workspace
                StartClone = game.Workspace.World:clone()
            elseif MsgS == "settings" then
                Plr.PlayerGui.Tools.Settings.Visible = true
            elseif MsgS == "cmds" or MsgS == "commands" then
                Plr.PlayerGui["CommandGui's"].Gui.KeyCharacter.Text = "Prefix - "..Prefix
                Plr.PlayerGui["CommandGui's"].Gui.Visible = true
            end
        end
    end)
end)
0
Thanks /.\ MarceIla 10 — 9y
Ad

Answer this question