Hello, I’m making a game so that you can learn Lua and write your own code.
How would I run the text from a textbox so that it would work as a normal script?
Hello, I’m making a game so that you can learn Lua and write your own code.
How would I run the text from a textbox so that it would work as a normal script?
May be wrong but I think you could use script.Source
Ok, I will do some research into that and let you know what I find
No ok it cannot be used, sorry
Yeah, I just saw that it is protected. Thanks for the help though
Note: script.Source is only for plugins, won’t work for normal scripts.
You will have to use loadstring()
function. Check this out: How to use loadstrings?
Thank you! I’ll see if this is what I’m looking for
When I tried testing it, I got this error:
loadstring() is not available
Also remember, loadsting() can only be used on Server Script, so you will have to send the text from client to server by using remote events. And then server will execute it.
I know, I used it on a server script. Specifically on serverscriptservice
Set LoadstringEnabled to true. (it’s a property of Server Script Service)
Just use loadstrings.
For an example
button.MouseButton1Click:Connect(function()
local Success, Error = pcall(function()
loadstring(tostring(textbox.Text))()
end)
if Success then
print("Code ran succesfully")
else
assert(false, Error)
end
end)