darraghd493

Basic Connection Manager

Oct 30th, 2025 (edited)
891
0
Never
4
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.07 KB | Source Code | 0 0
  1. --[[
  2.     Basic Connection Manager by darraghd493
  3.  
  4.     A basic Roblox connection manager.
  5. ]]
  6.  
  7. local Library = {
  8.     ActiveConnections = {};
  9. }
  10. Library.__index = Library
  11.  
  12. function Library.new()
  13.     local self = setmetatable({
  14.         ActiveConnections = {};
  15.     }, Library)
  16.     return self
  17. end
  18.  
  19. function Library:Add(connection: RBXScriptConnection)
  20.     table.insert(self.ActiveConnections, connection)
  21.     return connection
  22. end
  23.  
  24. function Library:Create(event: RBXScriptSignal, callback: (...any) -> ()): RBXScriptConnection
  25.     local connection = event:Connect(callback)
  26.     table.insert(self.ActiveConnections, connection)
  27.     return connection
  28. end
  29.  
  30. function Library:Remove(connection: RBXScriptConnection)
  31.     for i, conn in pairs(self.ActiveConnections) do
  32.         if conn == connection then
  33.             table.remove(self.ActiveConnections, i)
  34.             return
  35.         end
  36.     end
  37. end
  38.  
  39. function Library:Shutdown()
  40.     for i, conn in pairs(self.ActiveConnections) do
  41.         conn:Disconnect()
  42.     end
  43.     self.ActiveConnections = {}
  44. end
  45.  
  46. return Library
Advertisement
Comments
  • User was banned
  • User was banned
  • User was banned
  • User was banned
Add Comment
Please, Sign In to add comment