How to I run text from a textbox as a 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?

1 Like

May be wrong but I think you could use script.Source

1 Like

Ok, I will do some research into that and let you know what I find

This is it: Script.Source (

1 Like

No ok it cannot be used, sorry

1 Like

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?

1 Like

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

	local Success, Error = pcall(function()
	if Success then
		print("Code ran succesfully")
		assert(false, Error)
1 Like