I wanted to make a real time error checker for my in-game IDE, and I already know how to do it but I had a problem
The error checker worked… but it also executed the code
I tried looking for help but didn’t find any from online source
this was my code
ErrorCheckerRemote.OnServerEvent:Connect(function(Player, Code)
local Success, Error = pcall(function()
loadstring(Code)
end)
if Success then
print(Code)
print("no error")
else
print(Error)
end
end)
it printed the code and printed no error then I fire the remote event and the code is
print("hi")
the problem is it also ran the code print(“hi”) and I don’t want it to run, only check
any help? or ideas?
ErrorCheckerRemote.OnServerEvent:Connect(function(Player, Code)
local Success, Error = pcall(function()
loadstring(Code)
end)
if Success then
print(Code)
print("no error")
else
print(Error)
end
end)
sorry I forgot to save the script, it works!
but instead… it print “no error” even when the code that it checks have error
ErrorCheckerRemote.OnServerEvent:Connect(function(Player, Code)
local Success, Error = pcall(function()
loadstring(Code)()
end)
if Success then
print(Code)
print("no error")
else
print(Error)
end
end)
but… it ran the code when it checks
the thing is I only want it to check, I don’t want it to run the code is that possible??
use my module instead, i forgot how to use it link lol
local module = require(--[[module location]])
local output, isError = module:Compile(
"print('hello world')",
"lua-5.4.0"
)
if isError then
print('error xdxd')
else
print(output)
end
ErrorCheckerRemote.OnServerEvent:Connect(function(Player, Code)
local module = require(script.MainModule)
local output, isError = module:Compile(
'print("hi")',
"lua-5.4.0"
)
if isError then
print('error xdxd')
else
print(output)
end
end)
it printed “error xdxd” every time the remote event fire (but it delay a bit)
this was my code btw
ErrorCheckerRemote.OnServerEvent:Connect(function(Player, Code)
pcall(function()
print(Code)
local suc,err = loadstring(tostring(Code))
if suc then
print("suc")
else
print("err")
end
end)
end)