How would I make an in game Lua sandbox?

Wondering how I could make a Lua sandbox in game. The sandbox would allow players to give an output in a custom output box, while also making sure they cannot modify any of the game’s scripts and local scripts. Thank you in advance, and if you need any clarification on anything I will be happy to clarify!

Cheers,
Robyn

1 Like

what is “Lua sandbox”?

1 Like
3 Likes

Like how this game is able to execute code that the user writes in game.

oh I know how! now I understand

How then?

(303030303030303030)

First enable loadstring then write a script like this (put it in a TextBox)

local box = Instance.new('TextBox') local text = '' box.FocusLost:Connect(function() text = box.Text end) box.Focused:Connect(function() box.Text = text end) box.FocusLost:Connect(function(enter, input) if enter then print('enter') loadstring(box.Text) end end)

make local box script.parent

No, no. Please for the love of God don’t do this, It’s extremely dangerous and there’s a reason loadstring is disabled by default. Just use SLVM.

3 Likes

Just wondering, is SLVM what this game uses?

Possibly. If it isn’t SLVM, it is something similar, for sure.

Cool. Does SLVM (don’t know the name for this) format code like roblox studio?

No. SLVM just executes code.
(30 things)

1 Like

Is there any way to format the code like studio?

You’ll probably have to do that yourself.

Yeah i know that. Just curious: when a program has the colourful words, does it specifically check for those words and apply text formatting, or no?

Yep.
(30 “things” if yk what i mean (i mean characters))

Cool, I got that. One last thing (probably), how in the world is indentation and new lines created. With a textBox you can’t really do much. Would you create a new textbox every line? Wait. I think a textbox is able to create new lines if you press enter if I’m not mistaken… Or I’m terribly wrong.

If your looking for syntax highlighting (coloring certain keywords), you could use this. GitHub - boatbomber/Highlighter: RichText highlighting Lua code with a pure Lua lexer

3 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.