Is possible to get every RBXScriptConnection of an Instance?

Does anyone have an idea if it’s possible to get every RBXScriptConnection of an Instance (If it’s connected!)?

You can’t with given API methods, the best way to get all RBXScriptConnection objects of an instance is to store them yourself by making some sort of framework that stores and creates RBXScriptConnections for you.

1 Like

Alright, thanks for replying! Late i’ll try your idea.

Made a code structure for you to work off in case you didn’t know how to do what BenMactavsin suggested. The code is pretty ugly and should only be used as a reference and guide for accomplishing the end result. It was meant to just demonstrate how to achieve the goal.

local module = {}
local tab = {}

function module.Connect(Target : Instance, Type : string, Callback)
	if Target then
		if not tab[Target] then
			tab[Target] = {}
		end
			
		local co = #tab[Target] + 1
			
		tab[Target]["Connection"..co] = Target[Type]:Connect(function(param1, param2, param3)
			if param1 and param2 and param3 then
				Callback(param1, param2, param3)
			elseif param1 and param2 then
				Callback(param1, param2)
			elseif param2 and param3 then
				Callback(param2, param3)
			elseif param1 and param3 then
				Callback(param1, param3)
			elseif param1 then
				Callback(param1)
			elseif param2 then
				Callback(param2)
			elseif param3 then
				Callback(param3)
			end
		end)
			
		return tab[Target], co
	end
end

function module.Disconnect(Connection : RBXScriptConnection, Target, Number)
	if Connection then
		Connection:Disconnect()
	
		task.wait(0.1)
	
		tab[Target]["Connection"..Number] = nil
	end
end

function module.RetrieveList(Target)
	return tab[Target]
end

return module

And of course, here is a sample code:

Sample
local module = require(workspace.ConnectionLoader)
local target = workspace.Part

function callback(hit)
	print(hit.Name)
end

local connection, number = module.Connect(target, "Touched", callback)

local tab = module.RetrieveList(workspace.Part)
print(tab)

module.Disconnect(connection["Connection"..number], target, number)

local tab2 = module.RetrieveList(workspace.Part)
print(tab2)
1 Like