Hello. I’m revamping the scripting architecture for my game and I’ve made a module that can be used for RunService connections, though I was wondering if it’d be functional instead of having to make multiple connections overtime.
I’ve made a module that adds a table to a main table so it determines which method I’m using (Heartbeat, Stepped or RenderStepped) with its respective function. Here’s an example of how it works:
RunService.Heartbeat:Connect(function(...)
for _, v in ipairs(LOOPING_TABLE) do -- Loops through the table and checks if it is the respective method.
if v.Method == "Heartbeat" then
task.spawn(v.Function, ...) -- Spawns the function not having to wait for it to be done so the next can be called.
end
end
end)
The module has a function that returns a metatable and it has a Disconnect function that removes the function from the table so it can be no longer executed again. Any thoughts about if it could cause performance issues or something like that?