RobloxScripterAI
Discord ↗
Link Copied to Clipboard
×
"create a complexed admin script with multiple commands."
-- server script --[[ Admin Script This script allows for admins to use various commands to manage the game. Commands: /kick [player] [reason] - kicks the specified player from the game /ban [player] [reason] - bans the specified player from the game /mute [player] [reason] - mutes the specified player from the game /unmute [player] - unmutes the specified player from the game /tp [player1] [player2] - teleports player1 to player2 /freeze [player] - freezes the specified player /unfreeze [player] - unfreezes the specified player /warn [player] [reason] - warns the specified player /clearwarnings [player] - clears all warnings for the specified player /promote [player] [rank] - promotes the specified player to the specified rank /demote [player] [rank] - demotes the specified player to the specified rank /givecoins [player] [amount] - gives the specified player the specified amount of coins /takecoins [player] [amount] - takes the specified amount of coins from the specified player /addxp [player] [amount] - adds the specified amount of xp to the specified player /removexp [player] [amount] - removes the specified amount of xp from the specified player ]] --[[ Admin Command Functions ]] -- Kick a player local function kickPlayer(player, reason) player:Kick(reason) end -- Ban a player local function banPlayer(player, reason) player:Ban(reason) end -- Mute a player local function mutePlayer(player, reason) player.Muted = true player:Kick(reason) end -- Unmute a player local function unmutePlayer(player) player.Muted = false end -- Teleport one player to another local function teleportPlayer(player1, player2) player1.Character:MoveTo(player2.Character.PrimaryPart.Position) end -- Freeze a player local function freezePlayer(player) player.Character.Humanoid:ChangeState(Enum.HumanoidStateType.Frozen) end -- Unfreeze a player local function unfreezePlayer(player) player.Character.Humanoid:ChangeState(Enum.HumanoidStateType.Running) end -- Warn a player local function warnPlayer(player, reason) player.leaderstats.Warnings.Value = player.leaderstats.Warnings.Value + 1 player:Kick(reason) end -- Clear warnings for a player local function clearWarnings(player) player.leaderstats.Warnings.Value = 0 end -- Promote a player local function promotePlayer(player, rank) player.leaderstats.Rank.Value = rank end -- Demote a player local function demotePlayer(player, rank) player.leaderstats.Rank.Value = rank end -- Give coins to a player local function giveCoins(player, amount) player.leaderstats.Coins.Value = player.leaderstats.Coins.Value + amount end -- Take coins from a player local function takeCoins(player, amount) player.leaderstats.Coins.Value = player.leaderstats.Coins.Value - amount end -- Add xp to a player local function addXP(player, amount) player.leaderstats.XP.Value = player.leaderstats.XP.Value + amount end -- Remove xp from a player local function removeXP(player, amount) player.leaderstats.XP.Value = player.leaderstats.XP.Value - amount end --[[ Admin Command Handler ]] game.Players.PlayerAdded:Connect(function(player) player.Chatted:Connect(function(message) local args = message:split(" ") local command = args[1] if command == "/kick" then local targetPlayer = game.Players:FindFirstChild(args[2]) local reason = "" for i = 3, #args do reason = reason .. args[i] .. " " end kickPlayer(targetPlayer, reason) elseif command == "/ban" then local targetPlayer = game.Players:FindFirstChild(args[2]) local reason = "" for i = 3, #args do reason = reason .. args[i] .. " " end banPlayer(targetPlayer, reason) elseif command == "/mute" then local targetPlayer = game.Players:FindFirstChild(args[2]) local reason = "" for i = 3, #args do reason = reason .. args[i] .. " " end mutePlayer(targetPlayer, reason) elseif command == "/unmute" then local targetPlayer = game.Players:FindFirstChild(args[2]) unmutePlayer(targetPlayer) elseif command == "/tp" then local targetPlayer1 = game.Players:FindFirstChild(args[2]) local targetPlayer2 = game.Players:FindFirstChild(args[3]) teleportPlayer(targetPlayer1, targetPlayer2) elseif command == "/freeze" then local targetPlayer = game.Players:FindFirstChild(args[2]) freezePlayer(targetPlayer) elseif command == "/unfreeze" then local targetPlayer = game.Players:FindFirstChild(args[2]) unfreezePlayer(targetPlayer) elseif command == "/warn" then local targetPlayer = game.Players:FindFirstChild(args[2]) local reason = "" for i = 3, #args do reason = reason .. args[i] .. " " end warnPlayer(targetPlayer, reason) elseif command == "/clearwarnings" then local targetPlayer = game.Players:FindFirstChild(args[2]) clearWarnings(targetPlayer) elseif command == "/promote" then local targetPlayer = game.Players:FindFirstChild(args[2]) local rank = args[3] promotePlayer(targetPlayer, rank) elseif command == "/demote" then local targetPlayer = game.Players:FindFirstChild(args[2]) local rank = args[3] demotePlayer(targetPlayer, rank) elseif command == "/givecoins" then local targetPlayer = game.Players:FindFirstChild(args[2]) local amount = tonumber(args[3]) giveCoins(targetPlayer, amount) elseif command == "/takecoins" then