Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Creating the main GUI
- local gui = Instance.new("ScreenGui")
- gui.Name = "CommandsGUI_V2"
- gui.Parent = game.Players.LocalPlayer.PlayerGui
- -- Creating the Admin Frame
- local frame = Instance.new("Frame")
- frame.Name = "AdminFrame"
- frame.Size = UDim2.new(0, 300, 0, 400)
- frame.Position = UDim2.new(1, -310, 0.5, -200) -- Positioned at the right corner
- frame.BackgroundColor3 = Color3.fromRGB(50, 50, 50)
- frame.Active = true
- frame.Draggable = true
- frame.Parent = gui
- -- Creating the top label
- local topLabel = Instance.new("TextLabel")
- topLabel.Size = UDim2.new(1, 0, 0, 50)
- topLabel.Position = UDim2.new(0, 0, 0, 0)
- topLabel.Text = "Command GUI V2"
- topLabel.TextColor3 = Color3.fromRGB(255, 255, 255)
- topLabel.BackgroundColor3 = Color3.fromRGB(70, 70, 70)
- topLabel.TextSize = 20 -- Changed to 20
- topLabel.Parent = frame
- -- Creating the close button (X)
- local closeButton = Instance.new("TextButton")
- closeButton.Size = UDim2.new(0, 40, 0, 40)
- closeButton.Position = UDim2.new(1, -45, 0, 5) -- Positioned at the top-right corner
- closeButton.Text = "X"
- closeButton.TextColor3 = Color3.fromRGB(0, 0, 0) -- Black text
- closeButton.TextSize = 21 -- Text size set to 21
- closeButton.BackgroundColor3 = Color3.fromRGB(255, 0, 0) -- Red background
- closeButton.Parent = frame
- -- Close button functionality
- closeButton.MouseButton1Click:Connect(function()
- gui:Destroy() -- Closes the entire GUI
- end)
- -- Creating the command box
- local commandBox = Instance.new("TextBox")
- commandBox.Size = UDim2.new(1, -20, 0, 50)
- commandBox.Position = UDim2.new(0, 10, 0, 60)
- commandBox.PlaceholderText = "Type your command"
- commandBox.TextColor3 = Color3.fromRGB(255, 255, 255)
- commandBox.BackgroundColor3 = Color3.fromRGB(40, 40, 40)
- commandBox.TextSize = 20
- commandBox.Parent = frame
- -- Creating the status label
- local statusLabel = Instance.new("TextLabel")
- statusLabel.Size = UDim2.new(1, -20, 0, 40)
- statusLabel.Position = UDim2.new(0, 10, 0, 120)
- statusLabel.Text = "Status: Nothing"
- statusLabel.TextColor3 = Color3.fromRGB(255, 255, 255)
- statusLabel.BackgroundColor3 = Color3.fromRGB(50, 50, 50)
- statusLabel.TextSize = 20 -- Changed to 20
- statusLabel.Parent = frame
- -- Function to reset the status label after 5 seconds
- local function resetStatusLabel()
- wait(5)
- statusLabel.Text = "Status: Nothing"
- end
- -- Function to find a player by name or handle the "me" command
- local function findPlayerByName(name)
- if name == "me" then
- return game.Players.LocalPlayer
- end
- for _, player in ipairs(game.Players:GetPlayers()) do
- if player.Name == name or player.DisplayName == name then
- return player
- end
- end
- return nil
- end
- -- Function to apply a command to all players in the server
- local function allPlayers(action)
- for _, player in ipairs(game.Players:GetPlayers()) do
- action(player)
- end
- end
- -- Command Functions
- -- Ban function for a specific target or "me"
- local function banPlayer(targetName)
- local target = findPlayerByName(targetName)
- if target then
- target:Kick("You have been banned by an admin!")
- statusLabel.Text = "Status: " .. targetName .. " has been banned."
- else
- statusLabel.Text = "Status: Player not found."
- end
- resetStatusLabel()
- end
- -- Ban all players function
- local function banAllPlayers()
- allPlayers(function(player)
- player:Kick("You have been banned by an admin!")
- end)
- statusLabel.Text = "Status: All players have been banned."
- resetStatusLabel()
- end
- -- Kick function for a specific target or "me"
- local function kickPlayer(targetName)
- local target = findPlayerByName(targetName)
- if target then
- target:Kick("You have been kicked by an admin!")
- statusLabel.Text = "Status: " .. targetName .. " has been kicked."
- else
- statusLabel.Text = "Status: Player not found."
- end
- resetStatusLabel()
- end
- -- Kill a player or "me" by removing their Humanoid
- local function killPlayer(targetName)
- local target = findPlayerByName(targetName)
- if target and target.Character and target.Character:FindFirstChild("Humanoid") then
- target.Character.Humanoid.Health = 0
- statusLabel.Text = "Status: " .. targetName .. " has been killed."
- else
- statusLabel.Text = "Status: Player or Humanoid not found."
- end
- resetStatusLabel()
- end
- -- Kill all players function
- local function killAllPlayers()
- allPlayers(function(player)
- if player.Character and player.Character:FindFirstChild("Humanoid") then
- player.Character.Humanoid.Health = 0
- end
- end)
- statusLabel.Text = "Status: All players have been killed."
- resetStatusLabel()
- end
- -- Jail function to trap a player or "me" in a cell
- local function jailPlayer(targetName)
- local target = findPlayerByName(targetName)
- if target and target.Character then
- -- Create a "jail cell" around the player
- local jailCell = Instance.new("Part")
- jailCell.Size = Vector3.new(10, 10, 10)
- jailCell.Anchored = true
- jailCell.Position = target.Character.PrimaryPart.Position
- jailCell.Parent = workspace
- statusLabel.Text = "Status: " .. targetName .. " has been jailed."
- else
- statusLabel.Text = "Status: Player not found."
- end
- resetStatusLabel()
- end
- -- Unjail function to free a jailed player or "me"
- local function unjailPlayer(targetName)
- local target = findPlayerByName(targetName)
- if target then
- -- Remove the jail (Assume it's a part named "Jail")
- for _, part in ipairs(workspace:GetChildren()) do
- if part:IsA("Part") and part.Name == "Jail" then
- part:Destroy()
- end
- end
- statusLabel.Text = "Status: " .. targetName .. " has been unjailed."
- else
- statusLabel.Text = "Status: Player not found."
- end
- resetStatusLabel()
- end
- -- Teleport to a target player or "me"
- local function gotoPlayer(targetName)
- local target = findPlayerByName(targetName)
- if target and target.Character then
- game.Players.LocalPlayer.Character:SetPrimaryPartCFrame(target.Character.PrimaryPart.CFrame)
- statusLabel.Text = "Status: Teleported to " .. targetName
- else
- statusLabel.Text = "Status: Player not found."
- end
- resetStatusLabel()
- end
- -- Teleport all players to one target or "me"
- local function teleportAllToPlayer(targetName)
- local target = findPlayerByName(targetName)
- if target and target.Character then
- local targetPosition = target.Character.PrimaryPart.Position
- allPlayers(function(player)
- player.Character:SetPrimaryPartCFrame(CFrame.new(targetPosition))
- end)
- statusLabel.Text = "Status: All players teleported to " .. targetName
- else
- statusLabel.Text = "Status: Target player not found."
- end
- resetStatusLabel()
- end
- -- Command Parsing
- commandBox.FocusLost:Connect(function(enterPressed)
- if enterPressed then
- local input = commandBox.Text
- local split = string.split(input, " ")
- if split[1] == "!ban" then
- banPlayer(split[2])
- elseif split[1] == "!banall" then
- banAllPlayers()
- elseif split[1] == "!kick" then
- kickPlayer(split[2])
- elseif split[1] == "!kill" then
- killPlayer(split[2])
- elseif split[1] == "!killall" then
- killAllPlayers()
- elseif split[1] == "!jail" then
- jailPlayer(split[2])
- elseif split[1] == "!unjail" then
- unjailPlayer(split[2])
- elseif split[1] == "!goto" then
- gotoPlayer(split[2])
- elseif split[1] == "!tpall" then
- teleportAllToPlayer(split[2])
- else
- statusLabel.Text = "Status: Unknown command."
- end
- commandBox.Text = ""
- end
- end)
- -- Function to give a Boombox tool to the player
- local function giveBoombox(player)
- local tool = Instance.new("Tool")
- tool.Name = "Boombox"
- tool.RequiresHandle = false
- tool.CanBeDropped = false
- local remote = Instance.new("RemoteEvent")
- remote.Name = "PlaySound"
- remote.Parent = tool
- tool.Activated:Connect(function()
- local soundId = "rbxassetid://" .. player.Input -- Assuming the player inputs the sound ID
- if soundId then
- local sound = Instance.new("Sound", workspace)
- sound.SoundId = soundId
- sound:Play()
- end
- end)
- tool.Parent = player.Backpack
- statusLabel.Text = "Status: " .. player.Name .. " received a Boombox."
- resetStatusLabel()
- end
- -- Command to give Boombox to player or all
- local function giveBoomboxCommand(targetName)
- if targetName == "all" then
- allPlayers(function(player)
- giveBoombox(player)
- end)
- statusLabel.Text = "Status: All players received a Boombox."
- else
- local target = findPlayerByName(targetName)
- if target then
- giveBoombox(target)
- else
- statusLabel.Text = "Status: Player not found."
- end
- end
- resetStatusLabel()
- end
- -- Handle !boombox command
- commandBox.FocusLost:Connect(function(enterPressed)
- if enterPressed then
- local input = commandBox.Text
- local split = string.split(input, " ")
- if split[1] == "!boombox" then
- giveBoomboxCommand(split[2])
- end
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement