BetterConnections - A workaround for connections(?)

Hello people,
This is my first open source module so if I have done anything wrong don’t be afraid to tell me
Now this is V1 and I will be updating it so any bugs/fixes or even better optimization tips will be really apricated.

Anyways, this module is called BetterConnections
Roblox Model: https://create.roblox.com/store/asset/135494282669414/BetterConnections?viewFromStudio=true&keyword=&searchId=a60f1369-ef56-4ea5-95cd-8fa0537c786d
RBXM File:
BetterConnections.rbxm (5.6 KB)

Here is a example on how to use this module:

Example ServerScript:

local RunService = game:GetService("RunService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")

local Part = workspace:FindFirstChild("Part")
local Part2 = workspace:FindFirstChild("Part2")

local BetterConnections = require(script:FindFirstChild("BetterConnections"))
local PlayerConnections = {}
local GlobalConnections = BetterConnections.new()

function OnPlayerAdded(player : Player)
	PlayerConnections[player] = BetterConnections.new()
	if PlayerConnections[player] then
		PlayerConnections[player]:Connect("Heartbeat", RunService.Heartbeat, function(DeltaTime)
			if Part then
				Part.Position += Vector3.new(0, DeltaTime, 0)
			end
		end)
		PlayerConnections[player]:Connect("PostSim", RunService.PostSimulation, function(DeltaTime)
			print(DeltaTime)
		end)
		task.wait(0.2)
		PlayerConnections[player]:Disconnect("PostSim")
		PlayerConnections[player]:DebrisConnection(3, "Heartbeat2 (this is very original)", RunService.Heartbeat, function(Delta)
			print("Heartbeat still here")
		end)
		PlayerConnections[player]:DisconnectAll()
	end
end

function OnPlayerRemoving(player : Player)
	if PlayerConnections[player] then
		PlayerConnections[player]:Destroy()
	end
end

function GlobalConnectionSetup()
	GlobalConnections:Connect("KillBrick", Part2.Touched, function(BasePart)
		print(BasePart.Name)
	end)
end

Players.PlayerAdded:Connect(OnPlayerAdded)
Players.PlayerRemoving:Connect(OnPlayerRemoving)

GlobalConnectionSetup()

(i know the killbrick dosent kill my fault)
IMPORTANT: In the connect function in the module the code paramater is not suppost to be there i forgot to delete it so just leave it nil

anyways lmk if you find anything and feedback like I said is always appreciated thanks for your time.

4 Likes

hmm, this seems interesting, i’ve become pretty big on utilizing connections, so if you could include some documentation on using this that’d be great.

2 Likes

Yes I wouldn’t mind doing some documentation but that would have to wait for tomorrow, thanks for the feedback!

1 Like

alright then, and your welcome! from the example script shown, i like how functions are formatted, its similar to how i’ve been handling connections but cleaner.

2 Likes

Haha, thanks! by the way when you mean documentation do you mean a more detailed explanation on here or an external website

1 Like

no problem! and whichever works best, i’d personally prefer on here as i could bookmark this post to read the documentation whenever i need, but on a website is a good way too.

2 Likes

I’ll do it on here then, by the way any suggestions I could add for v.1.1 just asking see if you have any ideas, its okay if not

1 Like

Cause I’m curious, how is this better than using robloxs connections?

3 Likes

Well from my usage case I think its better, I think it’s really all about opinions and how you like your connections doing, for me I like storing them all in a table and having a few unique features.

2 Likes

i don’t have any currently, maybe you could add the ability to connect a connection to multiple tables, but honestly i have no complaints with this module, it’s small and seems to be just what i need! i’m also curious as to what the Code parameter does in the :Connect function.

2 Likes

Thanks! The code paramater is a mistake I should’ve deleted it. Which I have done now
(I will look into that suggestion sorry for not mentioning it early)

1 Like

12 hours later and I did the global connection wrong it should be fixed now
(I edited on mobile so not sure)

1 Like

@KingBlueDash I made a BetterConnectionsV2 with better stuff if you wanna check it out.