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

Im Making An Admin Script, How Would I Make Admin Only Chat Commands?

So How Will I Make Admin Only Chat Commands? And How Do I Make Some Of The Functions That Are Empty In The Script Shown Below: ~~ Script Here ~~

-- Admins/Banned Players
Admins = {"TheGrimDeathZombie"}
TempAdmins = {}
Owners = {"Your Name Here"}
CoOwners = {"Your Name Here"}
Banned = {"Your Worst Enemy Here"}
-- Admin Settings
Prefix = ":" -- For Example "Prefix"Kill Lopsidednuthead
-- VIP Admin
VIPAdmin = false
ItemID = 1
-- Group Admin
GroupAdmin = false
GroupID = 1
GroupRanks = {16}
--[[
	Group ranks is the ID of the rank for example:
	GroupAdmin = true
	GroupId = 93859385
	GroupRanks = {14,45,58}
	[the group ranks mentioned there would be something like TIER 3,TIER 4, ADMIN, VICE CAPTAIN Etc]
--]]
----------!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!----------
----------!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!----------
----------!!! PLEASE REFRAIN FROM EDITING ANY OF THE SCRIPTS UNLESS YOU KNOW WHAT YOU ARE DOING !!!----------
----------!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!----------
----------!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!----------
----------!!!         YOU DO NOT NEED TO EDIT ANYTHING IN THE SCRIPTS TO USE THIS ADMIN         !!!----------
----------!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!----------
----------!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!----------

function Noobify(player)
	local p = game.Players:FindFirstChild(player.Name)
	local character = p.Character
	p.Character.Torso.BrickColor = BrickColor.new("Bright blue")
	p.Character.Head.BrickColor = BrickColor.new("Bright yellow")
	p.Character["Left Arm"].BrickColor = BrickColor.new("Bright yellow")
	p.Character["Right Arm"].BrickColor = BrickColor.new("Bright yellow")
	p.Character["Left Leg"].BrickColor = BrickColor.new("Bright green")
	p.Character["Right Leg"].BrickColor = BrickColor.new("Bright green")
end


function Rainbowify(player)
	local p = game.Players:FindFirstChild(player.Name)
	local character = p.Character
	p.Character.Torso.BrickColor = BrickColor.Random()
	p.Character.Head.BrickColor = BrickColor.Random()
	p.Character["Left Arm"].BrickColor = BrickColor.Random()
	p.Character["Right Arm"].BrickColor = BrickColor.Random()
	p.Character["Left Leg"].BrickColor = BrickColor.Random()
	p.Character["Right Leg"].BrickColor = BrickColor.Random()
end


function Invisify(player)
	local p = game.Players:FindFirstChild(player.Name)
	local character = p.Character
	p.Character.Torso.Transparency = 1
	p.Character.Head.Transparency = 1
	p.Character["Left Arm"].Transparency = 1
	p.Character["Right Arm"].Transparency = 1
	p.Character["Left Leg"].Transparency = 1
	p.Character["Right Leg"].Transparency = 1
end


function Visify(player)
	local p = game.Players:FindFirstChild(player.Name)
	local character = p.Character
	p.Character.Torso.Transparency = 0
	p.Character.Head.Transparency = 0
	p.Character["Left Arm"].Transparency = 0
	p.Character["Right Arm"].Transparency = 0
	p.Character["Left Leg"].Transparency = 0
	p.Character["Right Leg"].Transparency = 0
end


function Ghostify(player)
	local p = game.Players:FindFirstChild(player.Name)
	local character = p.Character
	p.Character.Torso.Transparency = 0.5
	p.Character.Head.Transparency = 0.5
	p.Character["Left Arm"].Transparency = 0.5
	p.Character["Right Arm"].Transparency = 0.5
	p.Character["Left Leg"].Transparency = 0.5
	p.Character["Right Leg"].Transparency = 0.5
end


function RemoveLimbs(player)
	local p = game.Players:FindFirstChild(player.Name)
	local character = p.Character
	p.Character["Left Arm"]:Destroy()
	p.Character["Right Arm"]:Destroy()
	p.Character["Left Leg"]:Destroy()
	p.Character["Right Leg"]:Destroy()
end


function Vampify(player)
	local p = game.Players:FindFirstChild(player.Name)
	local character = p.Character
	character.Head.face.Texture = "http://www.roblox.com/asset/?id=272176568"
end


function Teleport(player,targetplayer)
	local p = game.Players:FindFirstChild(player.Name)
	local Targetp = game.Players:FindFirstChild(targetplayer.Name)
	p.Character:MoveTo(Targetp.Character.Torso.Position)
end


function Freeze(player)
	local p = game.Players:FindFirstChild(player.Name)
	local character = p.Character
	character.Torso.Anchored = true
end


function Thaw(player)
	local p = game.Players:FindFirstChild(player.Name)
	local character = p.Character
	character.Torso.Anchored = false
end


function Disco()
	
end


function Undisco()
	
end


function Strobe()
	
end


function Unstrobe()
	
end


function Travel(player,PlaceID)
	local tpclone = script.Teleport:Clone()
	tpclone.Parent = player.Backpack
	tpclone.PlaceID.Value = PlaceID
end


function Ban()
	
end


function Unban()
	
end


function Tempban()
	
end


function Kick(player)
	game.Players:FindFirstChild(player.Name):Kick()
end


function Explorer()
	
end


function ResetLighting()
	game.Lighting.FogEnd = 10000000
end


function ServerStrobe()
	
end


function UnStrobeServer()
	
end


function LockServer()
	
end


function UnlockServer()
	
end


function SetFog(newval)
	game.Lighting.FogEnd = newval
end


function Nuke()
	
end


function SetStat()
	
end


function MLG(player)
	local character = game.Players:FindFirstChild(player.Name).Character
	local shades = script.Version.DealWithItShades:Clone()
	local doge = script.Version.Doge:Clone()
	shades.Parent = character
	doge.Parent = character
	shades.Handle.Anchored = false
	shades.Handle.Transparency = 0
	doge.Handle.Anchored = false
	doge.Handle.Transparency = 0
end


function Goldify(player)
	local p = game.Players:FindFirstChild(player.Name)
	local character = p.Character
	p.Character.Torso.BrickColor = BrickColor.new("Bright yellow")
	p.Character.Head.BrickColor = BrickColor.new("Bright yellow")
	p.Character["Left Arm"].BrickColor = BrickColor.new("Bright yellow")
	p.Character["Right Arm"].BrickColor = BrickColor.new("Bright yellow")
	p.Character["Left Leg"].BrickColor = BrickColor.new("Bright yellow")
	p.Character["Right Leg"].BrickColor = BrickColor.new("Bright yellow")
	p.Character.Torso.Reflectance = 0.5
	p.Character.Head.Reflectance = 0.5
	p.Character["Left Arm"].Reflectance = 0.5
	p.Character["Right Arm"].Reflectance = 0.5
	p.Character["Left Leg"].Reflectance = 0.5
	p.Character["Right Leg"].Reflectance = 0.5
end


function Kill(player)
	local p = game.Players:FindFirstChild(player.Name)
	p.Character.Humanoid:TakeDamage(99999999)
end


function LoopKill()
	
end


function UnLoopKill()
	
end

1 comment

0

I also mean chat commands, just to let people know

1 answer

So I have been looking at your code and there are two main problems with it, the 1st is that you should not be using the players name at all. You should use UserId as this will not change if the player changes their name. The second problem is that you have not connected any of the functions to the chatted event so none of this code will work as an admin chat script.

You also lack the correct checking methods with the functions as running RemoveLimbs on the same placer twice will error as they do not have any limbs.

Example script that you can build upon, this is designed to be adapted easily with new groups ect. You may need to check the wiki on some of the methods I have used as they may be new to you:-

--[[
	Permission levels
	0 - run all commands (Super Admin)
	
	Add groups to the permissions list 
	
	You can expand this group as many times as you need
	just make shure that you setup the commands per group correctly
]]

local commandPrefix = ':'

-- Format [id of player] = permission level
local userList = {
	[1540993] = 1 -- this is my id
}

-- the list of commands, examples only
local commandList = {
	
	kill = function(data)
		if #data == 0 then return end -- we have no data
		local charModel = game.Workspace:FindFirstChild(table.concat(data[1], '	')) -- for player names with a space in
		if charModel then
			local hum = charModel:FindFirstChild('Humanoid')
			if hum then
				hum.Health = 0
			end
		end
	end,
	
	goldify = function(data) -- we get passed an array of data, 2 should be the 1st
		if #data == 0 then return end -- we have no data
		local charModel = game.Workspace:FindFirstChild(table.concat(data[1], '	'))
		if charModel then
			local brickColor = BrickColor.new("Bright yellow")
			for _, v in pairs(charModel:GetChildren()) do
				if v:IsA('BasePart') then
					v.BrickColor = brickColor
				end
			end
		end
	end,
	
	printMsg = function(msg)
		print(msg)
	end
}

-- group permission list, we do not include 0 as we will use the full list
--
-- group 1 could be admin
-- group 2 could be mods 
-- ect, this will allow you to change who can run what
local groupPermission = {
	[1] = {goldify = commandList.goldify, printmsg = commandList.printMsg},
	[2] = {printmsg = commandList.printMsg}
}

-- split the msg by word
local function splitMsg(msg)
	local tmp = {}
	for itm in msg:gmatch('[^%s]+') do -- you will need to look up pattens
		table.insert(tmp, itm) 
		
	end
	return tmp
end

-- runs a command 
local function runCommand(command, data)
	
	if #data == 0 then return 'No data' end
	if command[data[1]] then
		local func =  command[data[1]]
		table.remove(data, 1) -- remove the command
		local res, data = pcall(func, data)
		return {res, data}
	else
		return 'Command not found'
	end
end

-- we should only connect the chat event when we get a user in our list
game.Players.PlayerAdded:connect(function(plr)
	if userList[plr.UserId] then -- we check our list if we find a member then connect a chat event
		
		plr.Chatted:connect(function(msg, rec)
			print(msg)
			-- check for a prefix
			if msg:sub(1,1) == commandPrefix then
				if #msg <= 1 then return end -- msg is too small to run				
				
				local userLevel =  userList[plr.UserId]
				if not userLevel then return end -- user is not in the list but has the chatted event 
				local data = splitMsg(msg:sub(2, #msg)) -- remove the prefix and split by word
				
				if userLevel == 0 then
					-- run as super admin
					runCommand(commandList, data) -- could do something with the results
				elseif groupPermission[userLevel] then
					-- run commands in the group
					runCommand(groupPermission[userLevel], data)
				else
					-- user group id is not found					
				end
			end
		end)
	end
end)

The script above should only be used as an example, please commend if you do not understand how / why this script works but 1st check the wiki.

8 comments

0

this script would just make the whole admin script hell for me to make .-.

0

It is an example to show you how one can be made while takeing into account group privalages and safe processing. If there are parts that you do not understand pls comment.

0

I dont understand command list and everything below it

0

The command list is just a table of all functions that can be called, under that the group permissions is a table group that lists what commands can be called in what group.

0

i just want to say this was a rude answer as you can tell he isn't an advanced scripter.

0

I dont see how since it only uses tables, functions, if statements and loops. The string matching might be.

0

Well now i understand it since i have been reading up most of the stuff here on the wiki

0

Cool

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