Admin Commands
Local Script
Inside Frame
local rs = game:GetService('ReplicatedStorage')
local commandEvent = rs:WaitForChild('CommandEvent')
local frame = script.Parent
local enter = frame.Enter
local box = frame.CommandBox
--list of valid commands
local actions = {
'/kill' , '/freeze' , '/unfreeze' , '/hide' , '/show' , '/speed', '/jump',
'/trail', '/goto', '/find'
}
local needValue = {
'/speed', '/jump'
}
--make sure command is valid
local function valid_command(action)
for _,command in pairs(actions) do
if command == action then
return true
end
end
end
--make sure player exists
local function valid_player(person)
local player_table = {}
if person == 'me' then
local player = game.Players.LocalPlayer
table.insert(player_table, player)
elseif person == 'all' then
player_table = game.Players:GetChildren()
elseif person == 'noobs' then
player_table = game.Players:GetChildren()
for _, admin in pairs(game.ReplicatedStorage.Admins:GetChildren()) do
for pos, plr in pairs(game.Players:GetChildren()) do
if admin.Name == plr.Name then
table.remove(player_table, pos)
end
end
end
else
local player = game.Players:FindFirstChild(person)
if player then
table.insert(player_table, player)
else
return false
end
end
return player_table
end
local function valid_value(action, value)
for _,command in pairs(needValue) do
if command == action then
if not value then
return false
end
end
end
return true
end
--takes command and splits it up
local function get_command()
local command = {}
for word in string.gmatch(box.Text, "%S+") do
table.insert(command, word)
end
local action = command[1]
local person = command[2]
local value = command[3]
box.Text = ''
if valid_command(action)then
local player_table = valid_player(person)
if player_table then
if valid_value(action, value) then
commandEvent:FireServer(action, player_table, value)
else
box.Text = 'Value Error'
end
else
box.Text = 'Invalid Player'
end
else
box.Text = 'Invalid Command'
end
end
enter.MouseButton1Click:Connect(get_command)
Script (Admin)
ServerScriptService
local rs = game:GetService('ReplicatedStorage')
local commandEvent = rs:WaitForChild('CommandEvent')
--kill player function
local function kill_player(player)
player.Character.Humanoid.Health = 0
end
--freeze player function
local function freeze_player(player)
player.Character.Humanoid.WalkSpeed = 0
player.Character.Humanoid.JumpPower = 0
end
--unfreeze player function
local function unfreeze_player(player)
player.Character.Humanoid.WalkSpeed = 16
player.Character.Humanoid.JumpPower = 50
end
--hide player
local function hide_player(player)
for _, limb in pairs(player.Character:GetChildren()) do
if limb:IsA('BasePart') then
limb.Transparency = 1
if limb.Name == 'Head' then
limb.face.Transparency = 1
end
elseif limb:IsA('Accessory') then
limb.Handle.Transparency = 1
end
end
end
--show player
local function show_player(player)
for _, limb in pairs(player.Character:GetChildren()) do
if limb:IsA('BasePart') and limb.Name ~= 'HumanoidRootPart' then
limb.Transparency = 0
if limb.Name == 'Head' then
limb.face.Transparency = 0
end
elseif limb:IsA('Accessory') then
limb.Handle.Transparency = 0
end
end
end
--assign player speed
local function speed(player, value)
player.Character.Humanoid.WalkSpeed = value
end
--assign player jump
local function jump(player, value)
player.Character.Humanoid.JumpPower = value
end
--player trail
local function trail(player)
local trail = player.Character:FindFirstChild('Trail')
if not trail then
local newTrail = Instance.new('Trail')
newTrail.Parent = player.Character
newTrail.Attachment0 = player.Character.HumanoidRootPart.RootRigAttachment
newTrail.Attachment1 = player.Character.Head.NeckRigAttachment
newTrail.Color = ColorSequence.new(Color3.fromRGB(255, 0, 255), Color3.fromRGB(0,255,0))
else
trail:Destroy()
end
end
local function goto(admin, player)
admin.Character.HumanoidRootPart.CFrame = player.Character.HumanoidRootPart.CFrame
end
local function find(admin, player)
player.Character.HumanoidRootPart.CFrame = admin.Character.HumanoidRootPart.CFrame
end
--Main Function
local function do_command(admin, action, player_table, value)
for _, player in pairs(player_table) do
if action == '/kill' then
kill_player(player)
elseif action == '/freeze' then
freeze_player(player)
elseif action == '/unfreeze' then
unfreeze_player(player)
elseif action == '/hide' then
hide_player(player)
elseif action == '/show' then
show_player(player)
elseif action == '/speed' then
speed(player, value)
elseif action == '/jump' then
jump(player, value)
elseif action == '/trail' then
trail(player)
elseif action == '/goto' then
goto(admin, player)
elseif action == '/find' then
find(admin, player)
end
end
end
commandEvent.OnServerEvent:Connect(do_command)
Script (Users)
ServerScriptService
local admins = {
'Tech_Mike', 'Player1'
}
local function admin_check(player)
for _, admin in pairs(admins) do
if player.Name == admin then
return true
end
end
end
game.Players.PlayerAdded:Connect(function(player)
if admin_check(player) then
player.PlayerGui:WaitForChild('Admin').Frame.Visible = true
local adminValue = Instance.new('ObjectValue')
adminValue.Name = player.Name
adminValue.Value = player
adminValue.Parent = game.ReplicatedStorage.Admins
end
end)