โ† Back to all scripts

Admin Commands

Chat-based admin: /kick, /speed, /heal, /respawn with partial name matching.

AdminIntermediateServerScriptService
admin-commands.lua
-- Admin Commands
local ADMINS = { [000000000] = true }

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

game.Players.PlayerAdded:Connect(function(player)
    if not ADMINS[player.UserId] then return end
    player.Chatted:Connect(function(msg)
        local args = msg:split(" ")
        local cmd, target = args[1]:lower(), args[2] and findPlayer(args[2])
        if cmd == "/kick" and target then
            target:Kick(args[3] or "Kicked by admin.")
        elseif cmd == "/speed" and target and args[3] then
            local hum = target.Character and target.Character:FindFirstChildOfClass("Humanoid")
            if hum then hum.WalkSpeed = tonumber(args[3]) or 16 end
        elseif cmd == "/heal" and target then
            local hum = target.Character and target.Character:FindFirstChildOfClass("Humanoid")
            if hum then hum.Health = hum.MaxHealth end
        elseif cmd == "/respawn" and target then
            target:LoadCharacter()
        end
    end)
end)
Something broken or not working?
๐Ÿ”ง Try the AI Script Fixer โ†’