Modules, utilities

how do you use the ConnectionUtility in the roblox playermodule, it looks like it could be used to solve a lot of my problems So I wanna really check it out.

1 Like

Surely there’s another way to do what you are trying to do, i believe the modules inside playermodule aren’t really documented anywhere by roblox for a reason, but i believe it’s used to streamline and centralize how you connect, manage, and disconnect from events, helping to avoid issues like memory leaks from unhandled connections or multiple active connections for the same key. Perhaps try a garbage collection module such as Janitor | Janitor, or Maid to help with garbage collection.

2 Likes

I wanna do stuff like make custom services, like how you can do on Knit. But I don’t really know how to use Knit nor do I wanna learn right now.

1 Like

Services in Knit are just basic modulescripts required, and stored in a table, shared for example.

Service:

for _, v in script.Parent.Services:GetChildren() do
	if not v:IsA("ModuleScript") then
		continue
	end

	shared[v.Name] = require(v)
end

Then when you call Knit.Start() on the server, it goes through all the services (saved in shared in this example), and calls KnitInit, then KnitStart function in each

for _,service in shared do
    if type(service.KnitInit) == "function" then service:KnitInit() end
end

for _,service in shared do
    if type(service.KnitStart) == "function" then task.defer(function() service:KnitStart() end) end
end

GetService just returns the service stored in the table by that specific key)

Although it’s easy to do, i still recommend using Knit over this, it might seem scary at first, but it’s really easy to use, and is very well documented.

2 Likes

Great Insight, Usually it’d take like an essay for people to explain this but In a few lines I’m already seeing what you mean. I might take a look into knit if things get dire with my script organization. I’m already sitting on like 50 modulescripts

2 Likes

Thanks, it’s honestly all personal preference. If you are decent at organizing your scripts, breaking them all up into their separate components, services, and controllers, then you should be fine without using Knit, the amount of modulescripts you have doesn’t really matter as long as they are organized well and you are able to expand on it in the future.

2 Likes