What is the best way to disconnect from multiple events?

First post so I don’t know if this is the right category or not.
When handling multiple events with a for do loop what is the best way to disconnect from them? Is a simple :Disconnect() fine? Example:

local event
for i,v in pairs(buttonorsmthing:GetChildren() do
    event = v.Activated:Connect(function()
    -- blah blah blah
    end))
end
event:Disconnect()
local event --each time event is assigned the original value is overridden

for i, v in pairs(stuff:GetChildren()) do
	event = v.Activated:Connect(function()
		--do code
	end)	
end

event:Disconnect() --would only disconnect the most recent connection
local events = {}

for i, v in pairs(stuff:GetChildren()) do
	events[#events+1] = v.Activated:Connect(function()
		--do code
	end)	
end

for i, v in pairs(events) do
	i:Disconnect()
end
2 Likes

Was just about to ask the best way to do it. :sweat_smile: Thanks for your time!

what if


local P = game.ReplicatedStorage.RemoteEvent:Connect(function()

end)


P:Disconnect()

i think this can work