Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --StarterGui LocalScript
- -- Create a ScreenGui and a TextBox for code 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 executeButton = Instance.new("TextButton")
- executeButton.Size = UDim2.new(0, 200, 0, 50)
- executeButton.Position = UDim2.new(0.5, -100, 0.4, -25)
- executeButton.Text = "Execute"
- executeButton.Font = Enum.Font.SourceSansBold
- executeButton.TextSize = 18
- executeButton.Parent = gui
- -- Function to execute the code
- local function executeCode()
- local code = textBox.Text
- -- Execute the code using loadstring and pcall
- local success, dynamicFunction = pcall(loadstring, code)
- -- Display the result or error message
- if success then
- local status, error = pcall(dynamicFunction)
- if status then
- print("Code executed successfully!")
- else
- print("Error executing code: " .. tostring(error))
- end
- else
- print("Error loading code: " .. tostring(dynamicFunction))
- end
- -- Clear the input textbox
- textBox.Text = ""
- end
- -- Bind the executeCode function to the execute button click event
- executeButton.MouseButton1Click:Connect(executeCode)
- -- Function to clear the input textbox
- local function clearInput()
- textBox.Text = ""
- end
- -- Bind the clearInput function to the execute button double-click event
- executeButton.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.SourceSansBold
- 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()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement