Overwrite Roblox's Output functions?

I’m trying to find out (without Studio access) if any of this would work:

function warn(ProgramName, Missing)
   warn(ProgramName.." could not be opened because missing: "..Missing)
end

warn("Superscan", "blue frame")

I know it may be a recursive function but what if I change it to local or format it differently?

you can use logservice

local LogService = game:GetService("LogService")
Logservice.MessageOut:Connect(function(message, messageType)
print("The message was " .. message .. " and the type was " .. tostring(messageType))
end)
2 Likes

Assuming this is your own code? You can absolutely make a custom warn function but call it something else to avoid future confusion. Barring that, you can do exactly the method you’ve already mentioned.

do -- put the local _warn inside of a do-end block to prevent it being seen elsewhere
    local _warn = warn
    function warn(ProgramName, Missing) do
        _warn(`{ProgramName} could not be opened because missing: {Missing}`)
    end
end

You could do it with a ModuleScript and getfenv to automatically apply this change:

require(customWarn)()

but I won’t show you how to set that up because it’s not a good idea. getfenv might undo the progress Roblox has made in code optimizations for any script you use it in.


If this is for code that you don’t have control of (because it’s not your game, or it’s a private module or whatever), there isn’t really a good way.
There is also no way to apply the methods I’ve mentioned globally.

For that, I recommend @slendarcoolfan’s suggestion (thanks for saving me the typing btw) which is probably the most customizable, global, clean, and organized method at your disposal.

2 Likes

That’s not what I meant.


Why do I need the require, getfenv and the do in the code? They don’t seem to help with anything. Plus, I’m just trying to overwrite the warn function (in a single script) in order to print colored text for easier debugging.

Why got you to ask this? It surely is my game. I’m attempting to overwrite warn in one script.

Now i understand.
So you can do this instead:

local LogService = game:GetService("LogService")
Logservice.MessageOut:Connect(function(message, messageType)
if messageType == Enum.MessageType.MessageWarning then
print("--------------Warning!!-----------------")
print("Modifyed Version Of Message: "..message)
print("<The modifyed version of message>")
print("-----------------------------------------")
end
end)

No, what I mean is what’s in the main post:

local function warn_(...) 
	warn("do warn ",...)
end

local warn = warn_ 

warn(":this","should","work")

You can replace most Roblox global functions by creating a local variable with its name being the function name. Then, just set it to your custom function. The example above should print “do warn :this should work”

You should name it something else.
But this should work:

local warn = function(ProgramName, Missing)
   warn(ProgramName, "could not be opened because missing:", Missing)
end

@RickAstll3y, @savio14562, both seem promising to work. Unfortunately I’m gonna test these on Monday, so we’ll have to wait 'till then to see if the issue is fixed.

or you can use this:

local programname = "SuperScan"
local instancename = "Blue Frame"
local success,err = pcall(function()
local value = game.ServerScriptService[programname][instancename].Transparency
if value == 1 then
game.ServerScriptService[programname][instancename]:Destroy()
end
end)
if err then
if string.find(err,"is not a valid member") then
warn(programname.." could not scan because missing instance: "..instancename)
end
end

How did you come up with this??

you can check this forum for more details:

Doesn’t answer my question and there’s no connection between your reply and my question.