Help with getting Lua VM module working

So a while ago I wanted to make a Lua console, but that idea kind of died out since the code runs on the server, but then I saw the Lua VM module, and I decided to try and use it, but I never got it to work.

Server script inside of ServerScriptService:

local vm = require(game.ReplicatedStorage.Loadstring)

vm([[print("Hello world!")]])


Any help is appreciated!

Yes I already made another topic like this, but that was like 2 months ago and it has no replies so who cares.

is there a function inside of the module loadstring you can use? cos rn ur just calling a module as a function

1 Like

The module that is the parent to all the modules returns a function:

	Credit to einsteinK.
	Credit to Stravant for LBI.
	Credit to the creators of all the other modules used in this.
	Sceleratis was here and decided modify some things.
	einsteinK was here again to fix a bug in LBI for if-statements

local waitDeps = {

for i,v in pairs(waitDeps) do script:WaitForChild(v) end

local luaX = require(script.LuaX)
local luaY = require(script.LuaY)
local luaZ = require(script.LuaZ)
local luaU = require(script.LuaU)
local rerubi = require(script.FiOne)

local LuaState = {}

getfenv().script = nil

return function(str,env)
	local f,writer,buff,name
	local env = env or getfenv(2)
	local name = (env.script and env.script:GetFullName())
	local ran,error = pcall(function()
		local zio = luaZ:init(luaZ:make_getS(str), nil)
		if not zio then return error() end
		local func = luaY:parser(LuaState, zio, nil, name or "nil")
		writer, buff = luaU:make_setS()
		luaU:dump(LuaState, func, writer, buff)
		f = rerubi(, env)
	if ran then
		return f,
		return nil,error

Also, I’ve seen a few posts about Lua VM and it says to do what I am doing:

local vm =

vm("your code")
1 Like

Any errors? Also why do you have all those brackets and stuff, why not just do
vm("print("Hello world!"))

1 Like

Hey, sorry for the late response, I went to bed before you posted the reply, there is school today so I won’t be able to respond for a while, but, the brackets are basically a way of writing multiline strings, I used then so I could use normal quotation marks, and there were no errors, and nothing was in the output at all.

EDIT: vm("print("Hello world!")) would give an error because you didn’t close the starting string, and because a string that was started and ended with a " can’t have " inside of it.

My bad, forgot to think of that. Try this
vm("print('Hello world!')" )

If " is being used always use '

1 Like

I found one VM module myself, I got it working but it seems to work differently, now I can’t find it in the library but I have it saved in my games here’s an example of how to use it:


I have no idea why it’s formatted like that,

Link:I’ll post it later since I can’t rn on mobile

1 Like

If you want to use loadstring on the server, see LoadStringEnabled. Since the module is in ReplicatedStorage though you probably want to use it on the client.

This won’t do anything since vm here only turns the passed code into a function. You need to call the result:

vm([[print("Hello world!")]])()
1 Like

But loadstring is dangerous, and that’s a valid reason why we use custom loadstrings instead

No, it’s only as dangerous as using a custom loadstring module which @Babybunnyiscute19 is already doing.