Applying debounce to a part that is immediately destroyed

I have this code :

local debounce  = false
part.Touched:Connect(function(hit) 
	local player = Players:GetPlayerFromCharacter(hit.Parent)
	if player and not debounce then
		debounce = true
		part:Destroy()
	end
end)

this part is destroyed when a player touches it.Is it necessary to apply the Debounce technique taking into account that when the part is destroyed all its connections are cancelled (disconnected)?

And the same question for when I only perform the disconnection as in this code.

local debounce  = false
local connection
connection = part.Touched:Connect(function(hit) 
	local player = Players:GetPlayerFromCharacter(hit.Parent)
	if player and not debounce then
		debounce = true
		connection:Disconnect()
	end
end)
1 Like

I dont think you need a debounce for the destroy function

I mean, if I do these:

part.Touched:Connect(function(hit) 
	local player = Players:GetPlayerFromCharacter(hit.Parent)
	if player then
		part:Destroy()
	end
end)


local connection
connection = part.Touched:Connect(function(hit) 
	local player = Players:GetPlayerFromCharacter(hit.Parent)
	if player then
		connection:Disconnect()
	end
end)

I’ll never get any bounces?

Not that I know of
[30 Characters]

No, it wouldn’t be necessary.

When an object is destroyed, all connections to that object’s events are disconnected automatically, therefore you don’t need to explicitly destroy that other connection yourself.

This was very helpful, thank you for helping me.