This is our first open-source release. Please add a ⭐ if you like the idea of this project or if you like to use it.
Roblox Developer Forum Thread: https://devforum.roblox.com/t/3503750
Consider joining our community aswell! https://discord.gg/8ed3W53kHv/ to see progress on our very advanced projects and enjoy early-access benefits while you still can!
RBXConnectionManager is a lightweight and efficient module for managing RBXScriptConnection
objects in Roblox. It allows for easy connection handling, automatic cleanup, and optional event monitoring.
- Efficient Connection Management: Easily create, store, and disconnect connections by name.
- Automatic Cleanup: Removes player-specific connections when a player leaves (server-side feature) -> the player's UserId must be in the connection name.
- Batch Disconnection: Disconnect all connections or those within a specific group.
- Monitoring: Logs and displays event calls along with timestamps.
- Self-Destruction: Provides a method to completely clean up the manager.
- Add
RBXConnectionManager.luau
to your Roblox project. - Require the module where needed:
local RBXConnectionManager = require(path.to.rbxconnectionmanager)
local connectionManager = RBXConnectionManager.new()
local myEvent = game.ReplicatedStorage.SomeRemoteEvent
connectionManager:Connect("ExampleConnection", myEvent.OnServerEvent, function(player, data)
print("Event triggered by:", player.Name, "with data:", data)
end, true) -- Enable monitoring
connectionManager:Disconnect("ExampleConnection")
This will disconnect all events that contain the provided string in their name.
connectionManager:DisconnectAllInGroup("OnCarShowClicked")
connectionManager:DisconnectAll()
connectionManager:GetAllMonitoringData()
This will also disconnect all existing connections (like connectionManager:DisconnectAll() does)
connectionManager:Destroy()
This will disconnect all connections in group (group_name, like connectionManager:DisconnectAllInGroup) when an RBXScriptConnection (event) is fired
connectionManager:AddAutoDisconnect(group_name, event)
local Players = game:GetService("Players")
local RBXConnectionManager = require(game.ServerScriptService.rbxconnectionmanager)
-- Create a new connection manager
local connectionManager = RBXConnectionManager.new()
-- Example RemoteEvent
local remoteEvent = game.ReplicatedStorage.SomeRemoteEvent
-- Connect an event with automatic tracking
Players.PlayerAdded:Connect(function(playerObj)
local userid = playerObj.UserId
connectionManager:Connect("OnCarShowClicked_" .. tostring(userid), remoteEvent.OnServerEvent, function(triggeringPlayer, data)
print(triggeringPlayer.Name .. " triggered the event with data:", data)
warn("Send " .. triggeringPlayer.Name .. " congratulations about " .. triggeringPlayer.Name .. " clicking on his car show")
end, true) -- Enable monitoring
end)
- On the server-side, connections linked to a player will be automatically removed when they leave.
- Monitoring can be useful for debugging event calls, but it may have performance implications if used excessively.
- The module is designed to work efficiently in both server-side and client-side scripts.
This module is open-source and free to use in any Roblox project. Contributions and improvements are welcome!