Getting user specific output from console

Hey, I have a game which allows users to run (serverside) Lua with a Lua VM and I want to allow users to see their script output. Users could just check the console, but it would only show client output unless they were a creator of the game. I could just overwrite the basic output functions (print, warn, error, etc) but I wouldn’t be able to get output that doesn’t use those functions. I could use LogService, but I don’t know how I would be able to determine who’s output is who’s.

Any ideas?

For Roblox errors, I couldn’t say, just guessing which is who’s by referring to the time that each was given, though for printing or player made warnings or errors, id suggest just highjacking whenever one was made, then adding some ID to the start of the string of sorts with an end character, so whenever you get outputs, you just only read the ones with the players ID. An example of this would be like:

-player tries running “print(hello world”)"
-script detects that print and turns it into "print(“555555:” … “hello world”)
-outputs are received: “555555:hello world” “444444:other print”
-finds all outputs with player ID, and removes both playerID and the end character (the colon)
-gives local player an output of “hello world”

Just a little pseudocode example, of how you would do that. Perhaps you could do the same with any actual errors using Pcall and stuff, though I can’t exactly imagine how you would do that, nor how you could really place those inside the script without making a compiler or something. I’m sure people a lot smarter than me could figure out how though. Maybe you could do something similar really just going through the names of stuff wherever you can to try and put some ID somewhere, but I can’t really imagine exactly how without going into studio and experimenting myself.

1 Like