Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Moderator and Admin commands?

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

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

2 comments

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.

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.

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!

This discussion is preserved as it was. New answers, comments, and votes are closed.