Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to redirect server script and local script output to gui? (Filtering Enabled)

Asked by 5 years ago

I'm making a game where you complete obstacle courses by using a console given to you; This console can be switched to server or local mode which executes that code in the corresponding environment (Sandboxed and restricted of course). My trouble is that I don't know how to redirect output back to the player which would make debugging extremely painful. Maybe something along the lines of redefining the print function and the game's error handling to where it would check if that code was from a player, if so send the output back through a remote function and to the player's gui.

Pseudo-code:

_G.oldprint = print

print = function(message, player)
    oldprint(message)
    remoteevent:fireClient(player, message)
end

Execution error handling:

local status, err = pcall(ReceivedCode)
if status then
    print("Code executed successfully.", PlayerReceivedFrom) -- Using the print redefined earlier
else
    print("Code failed to run, Err: " .. err, PlayerReceivedFrom)
end

Any help is greatly appreciated!

0
I'm not sure where do you encounter a problem. Just connect to the remote event from the pseudo code and make it add messages to the gui. Amiaa16 3227 — 5y
0
Use LogService. I don't know how you are running code, so I can't really post an answer. hiimgoodpack 2009 — 5y
0
Using _G to make global variables is horrible practice. ModuleScripts > _G User#19524 175 — 5y

Answer this question