Advertisement
LikeRampage

CHATGPT Executor Roblox Script in Roblox Studio v2

Aug 12th, 2023
2,751
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.25 KB | None | 0 0
  1. --StarterGui LocalScript
  2. -- Create a ScreenGui and a TextBox for code input
  3. local gui = Instance.new("ScreenGui")
  4. gui.Parent = game.Players.LocalPlayer.PlayerGui
  5.  
  6. local textBox = Instance.new("TextBox")
  7. textBox.Size = UDim2.new(0, 200, 0, 50)
  8. textBox.Position = UDim2.new(0.5, -100, 0.3, -25)
  9. textBox.PlaceholderText = "Enter code"
  10. textBox.Font = Enum.Font.SourceSans
  11. textBox.TextSize = 18
  12. textBox.Parent = gui
  13.  
  14. -- Create a TextButton for the execute button
  15. local executeButton = Instance.new("TextButton")
  16. executeButton.Size = UDim2.new(0, 200, 0, 50)
  17. executeButton.Position = UDim2.new(0.5, -100, 0.4, -25)
  18. executeButton.Text = "Execute"
  19. executeButton.Font = Enum.Font.SourceSansBold
  20. executeButton.TextSize = 18
  21. executeButton.Parent = gui
  22.  
  23. -- Function to execute the code
  24. local function executeCode()
  25.     local code = textBox.Text
  26.  
  27.     -- Execute the code using loadstring and pcall
  28.     local success, dynamicFunction = pcall(loadstring, code)
  29.  
  30.     -- Display the result or error message
  31.     if success then
  32.         local status, error = pcall(dynamicFunction)
  33.         if status then
  34.             print("Code executed successfully!")
  35.         else
  36.             print("Error executing code: " .. tostring(error))
  37.         end
  38.     else
  39.         print("Error loading code: " .. tostring(dynamicFunction))
  40.     end
  41.  
  42.     -- Clear the input textbox
  43.     textBox.Text = ""
  44. end
  45.  
  46. -- Bind the executeCode function to the execute button click event
  47. executeButton.MouseButton1Click:Connect(executeCode)
  48.  
  49. -- Function to clear the input textbox
  50. local function clearInput()
  51.     textBox.Text = ""
  52. end
  53.  
  54. -- Bind the clearInput function to the execute button double-click event
  55. executeButton.MouseButton2Click:Connect(clearInput)
  56.  
  57. -- Create a TextButton for the destroy button
  58. local destroyButton = Instance.new("TextButton")
  59. destroyButton.Size = UDim2.new(0, 200, 0, 50)
  60. destroyButton.Position = UDim2.new(0.5, -100, 0.5, -25)
  61. destroyButton.Text = "Destroy GUI"
  62. destroyButton.Font = Enum.Font.SourceSansBold
  63. destroyButton.TextSize = 18
  64. destroyButton.Parent = gui
  65.  
  66. -- Function to destroy the GUI
  67. local function destroyGui()
  68.     gui:Destroy()
  69. end
  70.  
  71. -- Bind the destroyGui function to the destroy button click event
  72. destroyButton.MouseButton1Click:Connect(destroyGui)
  73.  
  74. -- Call the executeCode function to execute the initial code
  75. executeCode()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement