I need am trying to make a script execution GUI where you can paste/type a script into a text box and click an execute button to execute it, but when I execute it it doesn’t print the text I put in, but instead prints the text that was in it originally
Here’s the code
local ScrTxt = script.Parent.Parent.ScriptBox.Text
local Button = script.Parent
Button.MouseButton1Click:Connect(function()
print(ScrTxt)
end)
It is because you are printing the text of the textbox of the variable that was saved. (if you don’t change it, the variable will stay the same) So that’s why it will always be the same. You can change it to:
local ScrTxt = script.Parent.Parent.ScriptBox
local Button = script.Parent
Button.MouseButton1Click:Connect(function()
print(ScrTxt.Text)
end)
Then it will print the text of the textbox that is currently.
If you use a ServerSided script it will go through the Server instead of the Player… That being said, you won’t have to correct things. When doing things related to Player UI it is best to use Local scripts.
The way I imagine it the variable is already a basic string, It won’t change if the original source changes.
So you can either make the variable the textbox and print out the text property or you can not make a variable at all and print it