How to check if an instance is listening for an event like .Touched

Hello. I am currently trying to check if an event listener exists for a part. Is it possible to do that?

You believe can add a Variable to your Event:

local Event = script.Parent.Touched:Connect(SomeFunction)

print(Event.Connected) -- Bool
1 Like

yes, but how would I check if an instance is connected to that same event, without the variable? or any event, for that matter?

It is not possible there are simply no functions for it for an instance.

The only method is to organize and store your connections.

One method to make it easier is to use a shared table or global.

local connectionsTable = {}

local Event = script.Parent.Touched:Connect(SomeFunction)
--Store your connections in a dictionary table
connectionsTable[script.Parent.Touched] = {Event }

return connectionsTable

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.