Connect/disconnect events or leave the event alone with a flag?

So is it better to do something like

local flag = false

event:connect(function()
 if flag then
 --do stuff
 end
end)

while(true) do
 wait(5)
 flag = true
 wait(5)
 flag = false
end

or

local eventVar

while(true) do
 wait(5)

 eventVar = event:connect(function()
  --do stuff
 end)

 wait(5)
 eventVar:disconnect()
end

Only use Disconnect if you’re not gonna use the Event anymore. If you are lazy to reconnect it to the same function over and over again, Use the Flag.

Can’t believe people are able to answer these question so easily and so quick…

Spent an entire night yesterday worrying about that, I think I might have OCD.

1 Like