Disconnection script

local Players = game:GetService(“Players”)

Players.PlayerAdded:Connect(function(Player)
local Connections = {}

Player.CharacterAppearanceLoaded:Connect(function(Character)
	for _, v in pairs(Connections) do
		if v then
			v:Disconnect()
		end
	end
	
	Connections["Humanoid_Died"] = Character.Humanoid.Died:Connect(function()
		-- Do something
	end)
end)

end)

Don’t I need to do this?

When a ‘Humanoid’ dies it is destroyed (the time between it dying and it being destroyed being determined by the ‘Players.RespawnTime’ property). When a ‘Humanoid’ instance is destroyed any connections made from it are subsequently disconnected.

2 Likes

I’d recommend using :Once because sometimes Died can fire multiple times

1 Like

You can, though it really only becomes a problem when it’s constantly being looped. You’d be fine without it, but it won’t affect anything if you do have it.

Not better, not worse.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.