Is there a way to execute code on a client like how Adonis's .cs command does it?

i have been researching and researching on how Adonis managed to do it
but, i haven’t been able to get anything out of it
All i have found is that it uses the FiOne module, some core things and server.Dependencies.Loadstring which has some bytecode parsers

this is what i have tried but it keeps giving the same exact warning, no matter the environment (command bar, server, client)

code
local LoadStringModule = workspace.MainModule.Server.Dependencies.Loadstring
local FiOne = require(workspace.MainModule.Shared.FiOne)
local luaU = require(LoadStringModule.LuaU)
local luaY = require(LoadStringModule.LuaY)
local luaZ = require(LoadStringModule.LuaZ)
local getvenv = require(LoadStringModule.VirtualEnv)

local function CompileToBytecode(code, env)
    local f, buff
    local ran, err = xpcall(function()
        local zio = assert(luaZ:init(luaZ:make_getS(code), nil))
        local funcProto = luaY:parser({}, zio, nil, "::CommandBar::")
        local writer, buffObj = luaU:make_setS()
        luaU:dump({}, funcProto, writer, buffObj)
        f = FiOne.wrap_state(FiOne.bc_to_state(buffObj.data), env or getvenv())
    end, function(e)
        return e.."\n"..debug.traceback()
    end)
    if ran then
        return f, buff and buff.data
    else
        return nil, err
    end
end

local func, bytecode = CompileToBytecode('print("a command bar custom env test")')
if func then
    func()
else
    warn(bytecode)
end

the warning in question:

warning

Workspace.MainModule.Server.Dependencies.Loadstring.LuaX:914: attempt to index nil with ‘print’
local LoadStringModule = workspace.MainModule.Server.Dependencies.Loadstring
local FiOne = require(workspace.MainModule.Shared.FiOne)
local luaU = require(LoadStringModule.LuaU)
local luaY = require(LoadStringModule.LuaY)
local luaZ = require(LoadStringMo:17
Workspace.MainModule.Server.Dependencies.Loadstring.LuaX:914 function llex
Workspace.MainModule.Server.Dependencies.Loadstring.LuaX:727 function poptk
Workspace.MainModule.Server.Dependencies.Loadstring.LuaX:386 function next
Workspace.MainModule.Server.Dependencies.Loadstring.LuaY:703 function parser
local LoadStringModule = workspace.MainModule.Server.Dependencies.Loadstring
local FiOne = require(workspace.MainModule.Shared.FiOne)
local luaU = require(LoadStringModule.LuaU)
local luaY = require(LoadStringModule.LuaY)
local luaZ = require(LoadStringMo:12
local LoadStringModule = workspace.MainModule.Server.Dependencies.Loadstring
local FiOne = require(workspace.MainModule.Shared.FiOne)
local luaU = require(LoadStringModule.LuaU)
local luaY = require(LoadStringModule.LuaY)
local luaZ = require(LoadStringMo:10 function CompileToBytecode
local LoadStringModule = workspace.MainModule.Server.Dependencies.Loadstring
local FiOne = require(workspace.MainModule.Shared.FiOne)
local luaU = require(LoadStringModule.LuaU)
local luaY = require(LoadStringModule.LuaY)
local luaZ = require(LoadStringMo:26

so if anyone can help on this, it would be highly appreciated

1 Like

It works for me.

I just downloaded the Adonis MainModule, moved Shared.FiOne under Server.Loadstring, then put Server.Loadstring in a client script in StarterPlayerScripts with

require(script.Loadstring)('print("Hello, world!")")()

thank you!​​​​​​​​​​​​​​​​​​​​​​​