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

Moderator and Admin commands?

Asked by 9 years ago

I just recently decided to start making a game again for me and my friends to hang out, and I am having some issues. I want to make it so that when I join the game I have the capability to use moderator commands, and be able to give other commands to my friends; but since I have not touched the roblox studio stuff since late 2012, I am completely lost. I tried looking through the tutorials the studio provides but they seemed to be out-dated and I couldn't find anything. Any and all help at this point would be much appreciated, thank you for your time.

2 answers

Log in to vote
2
Answered by 9 years ago

Hi. If you want to run specific code whenever someone says something, you should look into implementing the Player.Chatted event.

game.Players.PlayerAdded:connect(function(player)
    player.Chatted:connect(function(msg)
        -- do stuff with msg and player
    end)
end)

You can then read the message and Player instance for each message. You might only want to allow certain players to run admin commands. For that you might want to do something like this:

local admins = {
    "frederikam",
    "kannsin34",
    "Player1",
}

local isAuthenticated = function(player)
    for i,v in ipairs(admins) do
        --Read the list for our admins
        --Compare our player to the admins
        if player.Name == v then--The player is an admin
            return true
        end
    end
    return false--Only run if the player's name did not match
end

Edit: I also recommend looking into http://wiki.roblox.com/index.php?title=Using_the_Chatted_event

0
Just a note: You can use the little globe icon when editing your post to add hyperlinks to other pages. Otherwise, very good answer. Spongocardo 1991 — 9y
0
Would I be able to change the "local admins" to something else that the system would consider "higher up" than admin? Meaning, is there something other than admin I could set with more privileges and capabilities? Thank you for your help so far, I am typing it up now, and testing it. kannsin34 0 — 9y
Ad
Log in to vote
0
Answered by 9 years ago

Adding on to the other guy's answer, this could double as a admin list or a ban script.

list = {["Person"] = true, ["LordDragonZord"] = true, ["Haker"] = false} --false is ban, true is admin, nil is neither

function admin(n)
    return list[n]
end

game:GetService("Players").PlayerAdded:connect(function(plyr)
    if admin(plyr.Name) then
        plyr.Chatted:connect(function(msg)
            if msg == "" then --If they say...
                --Code
            end
        end)
    elseif not admin(plyr.Name) then
        plyr:Kick("You've been banned") --Edit the message as you please.
    end
end)

Hope it helps!

Answer this question