Advertisement
VoidScripteay72

ee

Feb 28th, 2023
19
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.63 KB | None | 0 0
  1. -- Create the Console Tool
  2. local ConsoleTool = {}
  3.  
  4. -- Create the SurfaceGui
  5. local ConsoleGui = Instance.new("SurfaceGui")
  6. ConsoleGui.Name = "ConsoleGui"
  7. ConsoleGui.Enabled = true
  8.  
  9. -- Create the Frame for the Console
  10. local ConsoleFrame = Instance.new("Frame")
  11. ConsoleFrame.Name = "ConsoleFrame"
  12. ConsoleFrame.Size = UDim2.new(0, 250, 0, 150)
  13. ConsoleFrame.Position = UDim2.new(0.5, -125, 0.5, -75)
  14. ConsoleFrame.AnchorPoint = Vector2.new(0.5, 0.5)
  15. ConsoleFrame.BackgroundTransparency = 0.5
  16. ConsoleFrame.BackgroundColor3 = Color3.fromRGB(50, 50, 50)
  17. ConsoleFrame.Parent = ConsoleGui
  18.  
  19. -- Create the output box
  20. local Output = Instance.new("TextLabel")
  21. Output.Name = "Output"
  22. Output.Size = UDim2.new(1, 0, 0.8, 0)
  23. Output.Position = UDim2.new(0, 0, 0.2, 0)
  24. Output.BackgroundTransparency = 0.8
  25. Output.BackgroundColor3 = Color3.fromRGB(0, 0, 0)
  26. Output.TextColor3 = Color3.fromRGB(255, 255, 255)
  27. Output.TextWrapped = true
  28. Output.TextXAlignment = Enum.TextXAlignment.Left
  29. Output.TextYAlignment = Enum.TextYAlignment.Top
  30. Output.Font = Enum.Font.SourceSans
  31. Output.TextSize = 18
  32. Output.Text = ""
  33. Output.Parent = ConsoleFrame
  34.  
  35. -- Create the input box
  36. local Input = Instance.new("TextBox")
  37. Input.Name = "Input"
  38. Input.Size = UDim2.new(1, 0, 0.2, 0)
  39. Input.Position = UDim2.new(0, 0, 0.8, 0)
  40. Input.ClearTextOnFocus = true
  41. Input.Parent = ConsoleFrame
  42.  
  43. -- Connect the input box's FocusLost event to execute the command
  44. Input.FocusLost:Connect(function(enterPressed)
  45. if enterPressed then
  46. local command = Input.Text
  47. Input.Text = ""
  48.  
  49. -- Execute the command and output the result
  50. local success, result = pcall(function()
  51. return loadstring(command)()
  52. end)
  53.  
  54. if success then
  55. Output.Text = tostring(result)
  56. else
  57. Output.Text = "Error: " .. tostring(result)
  58. end
  59. end
  60. end)
  61.  
  62. -- Create the activate and deactivate functions for the Console Tool
  63. function ConsoleTool:Activate()
  64. -- Show the SurfaceGui in the player's backpack
  65. local player = game:GetService("Players").LocalPlayer
  66. local backpack = player.Backpack
  67. local tool = backpack:FindFirstChild("ConsoleTool")
  68. if not tool then
  69. tool = Instance.new("Tool")
  70. tool.Name = "ConsoleTool"
  71. tool.Parent = backpack
  72. self.Handle = tool
  73. end
  74. ConsoleGui.Parent = tool
  75. tool.Parent = player.Character
  76. end
  77.  
  78. function ConsoleTool:Deactivate()
  79. -- Hide the SurfaceGui and move it back to the player's backpack
  80. local player = game:GetService("Players").LocalPlayer
  81. local backpack = player.Backpack
  82. local tool = backpack:FindFirstChild("ConsoleTool")
  83. if tool then
  84. tool.Parent = backpack
  85. ConsoleGui.Parent = nil
  86. self.Handle = nil
  87. end
  88. end
  89.  
  90. return ConsoleTool
  91.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement