Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Create the Console Tool
- local ConsoleTool = {}
- -- Create the SurfaceGui
- local ConsoleGui = Instance.new("SurfaceGui")
- ConsoleGui.Name = "ConsoleGui"
- ConsoleGui.Enabled = true
- -- Create the Frame for the Console
- local ConsoleFrame = Instance.new("Frame")
- ConsoleFrame.Name = "ConsoleFrame"
- ConsoleFrame.Size = UDim2.new(0, 250, 0, 150)
- ConsoleFrame.Position = UDim2.new(0.5, -125, 0.5, -75)
- ConsoleFrame.AnchorPoint = Vector2.new(0.5, 0.5)
- ConsoleFrame.BackgroundTransparency = 0.5
- ConsoleFrame.BackgroundColor3 = Color3.fromRGB(50, 50, 50)
- ConsoleFrame.Parent = ConsoleGui
- -- Create the output box
- local Output = Instance.new("TextLabel")
- Output.Name = "Output"
- Output.Size = UDim2.new(1, 0, 0.8, 0)
- Output.Position = UDim2.new(0, 0, 0.2, 0)
- Output.BackgroundTransparency = 0.8
- Output.BackgroundColor3 = Color3.fromRGB(0, 0, 0)
- Output.TextColor3 = Color3.fromRGB(255, 255, 255)
- Output.TextWrapped = true
- Output.TextXAlignment = Enum.TextXAlignment.Left
- Output.TextYAlignment = Enum.TextYAlignment.Top
- Output.Font = Enum.Font.SourceSans
- Output.TextSize = 18
- Output.Text = ""
- Output.Parent = ConsoleFrame
- -- Create the input box
- local Input = Instance.new("TextBox")
- Input.Name = "Input"
- Input.Size = UDim2.new(1, 0, 0.2, 0)
- Input.Position = UDim2.new(0, 0, 0.8, 0)
- Input.ClearTextOnFocus = true
- Input.Parent = ConsoleFrame
- -- Connect the input box's FocusLost event to execute the command
- Input.FocusLost:Connect(function(enterPressed)
- if enterPressed then
- local command = Input.Text
- Input.Text = ""
- -- Execute the command and output the result
- local success, result = pcall(function()
- return loadstring(command)()
- end)
- if success then
- Output.Text = tostring(result)
- else
- Output.Text = "Error: " .. tostring(result)
- end
- end
- end)
- -- Create the activate and deactivate functions for the Console Tool
- function ConsoleTool:Activate()
- -- Show the SurfaceGui in the player's backpack
- local player = game:GetService("Players").LocalPlayer
- local backpack = player.Backpack
- local tool = backpack:FindFirstChild("ConsoleTool")
- if not tool then
- tool = Instance.new("Tool")
- tool.Name = "ConsoleTool"
- tool.Parent = backpack
- self.Handle = tool
- end
- ConsoleGui.Parent = tool
- tool.Parent = player.Character
- end
- function ConsoleTool:Deactivate()
- -- Hide the SurfaceGui and move it back to the player's backpack
- local player = game:GetService("Players").LocalPlayer
- local backpack = player.Backpack
- local tool = backpack:FindFirstChild("ConsoleTool")
- if tool then
- tool.Parent = backpack
- ConsoleGui.Parent = nil
- self.Handle = nil
- end
- end
- return ConsoleTool
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement