CyberMax
CyberMax › Answers

Roblox admin commands script with ranks (for your own game)

Updated 2026-10-17 · Roblox and game developers · by CyberMax

Short answer

Listen to chat on the server, check the speaker's UserId against an admin list, parse the message (":kick name reason") and run the command only on the server. With TextChatService, create TextChatCommands or read messages from Player.Chatted; never trust a rank sent by the client.

Copy-paste code

ServerScriptService/Admin.server.lua

local Players = game:GetService("Players")

local ADMINS = { [123456] = "owner", [234567] = "mod" } -- UserIds
local PREFIX = ":"

local function findPlayer(name)
	name = string.lower(name or "")
	for _, p in Players:GetPlayers() do
		if string.sub(string.lower(p.Name), 1, #name) == name then return p end
	end
end

local COMMANDS = {
	kick = function(admin, target, ...)
		if target then target:Kick(table.concat({ ... }, " ")) end
	end,
	speed = function(admin, target, value)
		local hum = target and target.Character and target.Character:FindFirstChildOfClass("Humanoid")
		if hum then hum.WalkSpeed = math.clamp(tonumber(value) or 16, 0, 100) end
	end,
	tp = function(admin, target)
		local a, b = admin.Character, target and target.Character
		if a and b then a:PivotTo(b:GetPivot() * CFrame.new(0, 0, 3)) end
	end,
}

Players.PlayerAdded:Connect(function(player)
	player.Chatted:Connect(function(msg)
		if not ADMINS[player.UserId] or string.sub(msg, 1, 1) ~= PREFIX then return end
		local args = string.split(string.sub(msg, 2), " ")
		local cmd = COMMANDS[string.lower(table.remove(args, 1) or "")]
		if cmd then
			print("[admin]", player.Name, msg) -- keep a log
			cmd(player, findPlayer(table.remove(args, 1)), table.unpack(args))
		end
	end)
end)

Good to know

This is for admin commands in a game you own. Scripts that claim to give admin in other people's games are exploits and break Roblox's Terms.

Use UserIds, not names: names can be changed.

Gavelwick Admin Commands: Admin commands with ranks, bans and a log

from $7

Gavelwick is a tested admin kit: 38 commands behind a typed parser, ranks from user ids, group ranks and game passes, smart player targeting, timed and permanent bans synced across servers, and an audit log.

Secure checkout · 14-day fix-or-refund if it doesn't work as described (terms)

Questions

Does Player.Chatted work with TextChatService?

Yes, Player.Chatted still fires for messages sent through the default chat. TextChatCommand objects are an alternative with autocomplete.

How do I add bans that persist?

Save banned UserIds in a DataStore and check them in PlayerAdded; Roblox also has a built-in Players:BanAsync API.

Free: the Roblox Starter Kit

7 free Luau modules (damage, pets, shop formatting, admin audit log, tycoon guards and more) plus 3 free calculators, then 5 short emails with the scripting fixes we see go wrong most often.

You get one email to confirm first. Then the kit, and 5 short emails over two weeks. One-click unsubscribe in every email; we never share your address.

Related answers

Roblox round system: intermission, round timer and winnersA server loop for round-based games: wait for enough players, intermission countdown, teleport in, round timerA Roblox DataStore save script that never wipes player dataCopy-paste Luau for loading and saving player data with DataStoreService: retries, UpdateAsync, BindToClose an