Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --StarterGui LocalScript
- -- Create a ScreenGui and a TextBox for input
- local gui = Instance.new("ScreenGui")
- gui.Parent = game.Players.LocalPlayer.PlayerGui
- local textBox = Instance.new("TextBox")
- textBox.Size = UDim2.new(0, 200, 0, 50)
- textBox.Position = UDim2.new(0.5, -100, 0.3, -25)
- textBox.PlaceholderText = "Enter code"
- textBox.Font = Enum.Font.SourceSans
- textBox.TextSize = 18
- textBox.Parent = gui
- -- Create a TextButton for the execute button
- local button = Instance.new("TextButton")
- button.Size = UDim2.new(0, 200, 0, 50)
- button.Position = UDim2.new(0.5, -100, 0.4, -25)
- button.Text = "Execute"
- button.Font = Enum.Font.SourceSansBold
- button.TextSize = 18
- button.Parent = gui
- -- Function to execute the code
- local function executeCode()
- local code = textBox.Text
- -- Execute the code using loadstring
- local success, result = pcall(loadstring(code))
- -- Display the result or error message
- if success then
- print("Code executed successfully!")
- else
- print("Error executing code: " .. tostring(result))
- end
- -- Clear the input textbox
- textBox.Text = ""
- end
- -- Bind the executeCode function to the button click event
- button.MouseButton1Click:Connect(executeCode)
- -- Function to clear the input textbox
- local function clearInput()
- textBox.Text = ""
- end
- -- Bind the clearInput function to the button double-click event
- button.MouseButton2Click:Connect(clearInput)
- -- Create a TextButton for the destroy button
- local destroyButton = Instance.new("TextButton")
- destroyButton.Size = UDim2.new(0, 200, 0, 50)
- destroyButton.Position = UDim2.new(0.5, -100, 0.5, -25)
- destroyButton.Text = "Destroy GUI"
- destroyButton.Font = Enum.Font.SourceSans
- destroyButton.TextSize = 18
- destroyButton.Parent = gui
- -- Function to destroy the GUI
- local function destroyGui()
- gui:Destroy()
- end
- -- Bind the destroyGui function to the destroy button click event
- destroyButton.MouseButton1Click:Connect(destroyGui)
- -- Call the executeCode function to execute the initial code
- executeCode()
- -- Run the code continuously
- while wait(1) do
- executeCode()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement