I was helping forcefully a friend learn OOP, by rewriting a module of theirs into an OOP module, because the thing he was trying to achieve was the exact thing you’d use it for. There was one element of his script that had me pondering though, and it looked something like this:
local Objects = {}
task.spawn(function()
Runservice.Heartbeat:Connect(function()
for i,v in Objects do
if ... then
...
end
end
end)
end)
In short: He had a table of non-OOP objects (Objects), with heartbeat connection that’d iterate through all the objects, but my intuition tells me that this would be an unorthodox way of operating an OOP module, but at the same time, if he had made a heartbeat connection for each object individually in an actual OOP module, would that be less efficient, if so, by “how much”?
function Object.new()
local self = setmetatable(...)
self._Loop = Runservice.Heartbeat:Connect(...)
end
I guess this just boils down to how connections work at a low level