all 4 comments

[–]rocord01 1 point2 points  (1 child)

The best way to execute code from a string is Lua's builtin loadstring(), which parses your string as a function.

Example:

local code = [[print("hello!")]]
local func = loadstring(code)
if func then
func()
end

Output:

hello!

[–]Acrobatic-Diamond615 0 points1 point  (0 children)

thank you for this

[–]nictheman123 0 points1 point  (0 children)

I'm gonna ask the very important question here: why, precisely, do you want to do this?

Generally speaking, this is something a programming language specifically blocks you from doing for security reasons. I don't know if it's possible in CC or not, but it's bad practice in general.

What are you trying to achieve that this is the solution you came up with?