Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[
- Basic Connection Manager by darraghd493
- A basic Roblox connection manager.
- ]]
- local Library = {
- ActiveConnections = {};
- }
- Library.__index = Library
- function Library.new()
- local self = setmetatable({
- ActiveConnections = {};
- }, Library)
- return self
- end
- function Library:Add(connection: RBXScriptConnection)
- table.insert(self.ActiveConnections, connection)
- return connection
- end
- function Library:Create(event: RBXScriptSignal, callback: (...any) -> ()): RBXScriptConnection
- local connection = event:Connect(callback)
- table.insert(self.ActiveConnections, connection)
- return connection
- end
- function Library:Remove(connection: RBXScriptConnection)
- for i, conn in pairs(self.ActiveConnections) do
- if conn == connection then
- table.remove(self.ActiveConnections, i)
- return
- end
- end
- end
- function Library:Shutdown()
- for i, conn in pairs(self.ActiveConnections) do
- conn:Disconnect()
- end
- self.ActiveConnections = {}
- end
- return Library
Advertisement