Right now a lot of my code variable declaration looks like this:

--Connections--
local rbDownConn = nil
local rbUpConn = nil
local lbDownConn = nil
local lbUpConn = nil
local heartbeat = nil
local keyDetection = nil

--When equip--
heartbeat = RunService.Heartbeat:Connect(makeSpread)

--When unequip--
if heartbeat then heartbeat:Disconnect() end

I connect them all in .equip and disconnect in .unequip of my tool. But... should I even do this? Is this something ok to do or I can just use :connect and expect tool internal to clear connections on unequip?

Just something I can't find info about

3 comments

0

Sure, that's fine, as long as that is your goal, to only call makeSpread() while tool is equipepd

0

What you're doing is fine, and is probably a more recommended way of going about this than what I've seen other people try and do in the past. In fact, I use a very similar technique for updating objects and when the objects are gone I just disconnect the event.

0

Ok tnx for the replies I just thought keeping a lot of connections might not be really good for memory