I am making a simple API which allows scripts to interact privately with each other.
Right now, I am trying to figure out if you could detect when a RBXScriptSignal:Connect() has been fired. Not the function.
Example of what I mean.
game:GetService("RunService").Heartbeat -- RBXScriptSignal
----------------------------------------------------------------
game:GetService("RunService").Heartbeat:connect(function() -- The function.
end)
What prevents me from making this is that I need to detect when that has been fired to prevent unauthorized access to the event. You may ask âWhy donât you just make the âeventâ like imaginary, like they are actually communicating privately?â and hereâs my answer: I want it to be compatible with every script, and make it so if unauthorized scripts try to access it, it needs permission from the script that made the event.
Suggestions, Questions and answers are appreciated.
I dont think you can detect listener in script as some may made in client some might be script and scripts dont have the power to read other script except for module
Specifically, I am using a modulescript. Not a script.
You can read contents in a script from a modulescript, but it is extremely complicated and roblox limits most features, which allows you to only see globalized functions(a function in which itâs not localized.)
I donât use this though because youâre not creating a whole new function for the event, but you also donât know if they are.
And you canât detect if the function is getting added yet.
Also, iâm pretty sure exploits can only do it, not client. Client canât do it normally, but exploits can because roblox limits most features as I said before.
You canât do that on services, like RunService. But if you made a wrapper for it, you could override the :Connect() methods and fire signals internally. Thatâs what I would do.
Well, thinking logically, they wouldnât allow us to make a wrapper for it anyways, because most of Robloxâs services are locked by metatables, so that way is no good.
local RunService = game:GetService("RunService")
local RunServiceWrapper = {}
function RunServiceWrapper:BindToRenderStepped(name, callback)
-- Pretend this is a signal or bindable event
RunServiceWrapper.RenderSteppedBound:Fire()
RunService:BindToRenderStep(name, Enum.RenderPriority.Last, callback)
end
function RunServiceWrapper:UnbindFromRenderStepped(name)
-- Pretend this is a signal or bindable event
RunServiceWrapper.RenderSteppedUnbound:Fire()
RunService:UnbindFromRenderStep(name)
end
return RunServiceWrapper
Yeah I mean this would be the same as just referencing RunService:BindToRenderStep(). But I think in this case itâs worth it to require the extra module, because of the features you can add.
Realistically youâd be requiring this module in place of RunService, so itâs basically the same thing. Wrappers are very powerful and should be used frequently.
You are correct.
I guess it wouldnât hurt to add another module, thanks for helping. I will mark your comment as the solution after I get the extra module working.