Is it Possible To run code through strings

Running Code Through Strings


I have been creating my own in-game developer console and making it more easily for other players to use (Other than devs) to run code in-games (Such as Moderators) to help me debug the game. Moderators don’t need developer permissions so I don’t give dev perms. Due to this they can’t access the command line in the developer console so I created my own but I ran into a issue when creating a new command line. I can’t figure out how to take the code they enter into line and run it as if it wasn’t a string but code. I don’t really want to use loadstring() because its super unsafe but want to still run code. I seen adonis (Admin System) has created something similar without using loadstring() and was wondering if it is possible to create a system to run code in a command bar without using loadstring().

I have checked this forum for any support that others had in the past but didn’t find anything. I also checked YouTube but failed as well. I am hoping this post helps.

3 Likes

Have you tried making two different strings and have them concatenated? If this isn’t what you mean, let me know.

No. I am trying to write code under a TextBox and turn what was written into code.

From my knowledge I don’t believe there’s any other way to do so. I think the source property of scripts can also only be set from the Studio environment.

If you’re persistent as to wanting to inject code at runtime, either way it’s not “safe”. If exploiters get through any wall of protection with server-sided checks they can execute anything that they want. So it should always be unsafe.

I’ve made something similar which works. Why don’t you pass the code into a remote event and pass to the server? Without using loadstring it is a lot harder to run safe code, so I do recommend you implement your own sandbox with restrictions, etc using getfenv and setfenv.

Also I recommend you take a look at this as one of the features is having functionality of loadstring without needing loadstringenabled: vLua 5.1 (improved VM) - Roblox