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!