Do GetPropertyChangedSignal listeners stack after resets?

Hello everyone,

I have a question about how event listeners work in Roblox when resetting a character multiple times. I’m working with a script that listens to a Humanoids Health property change using GetPropertyChangedSignal("Health"), and I’m curious if event listeners accumulate in memory when the character resets.

Here’s the code I’m working with:

local healthBarModule = require(game:GetService("ServerScriptService").Modules.HealthBarManager)

game.Players.PlayerAdded:Connect(function(plr)
	plr.CharacterAdded:Connect(function(char)
		
		-- Make Sure the Character has a Humanoid
		local hum = char:FindFirstChildOfClass("Humanoid")
		if not hum then
			warn("no humanoid of: "..plr.Name)
			return
		end
		
		-- Add HealthBar to the new Character
		healthBarModule.Add(char)
		print("HealthBar added")
		
		-- If the health changes, update the Health Bar:
		hum:GetPropertyChangedSignal("Health"):Connect(function()
			print("hello")
			healthBarModule.Update(char)
		end)
		
	end)
end)

The Question:

If a player resets their character multiple times (let’s say 10 times), does each reset cause a new GetPropertyChangedSignal("Health") event listener to accumulate in memory? In other words, after 10 resets, would there be 10 active listeners in memory, and if the health changes, would it print “hello” 10 times?

From my understanding, the event listener should only be registered once per character, even if the character is reset. However, I’m unsure if Roblox automatically cleans up old event listeners when the character resets, and that’s why I’m asking here.

Can someone clarify whether these listeners do accumulate, or if they are properly cleaned up when the character resets?

Thanks in advance for any insights!

you might find this reply helpful

Okay,
so a new event will be always registered,
if the character respawns and the workspace property is “disable”

but if I reset my character 3 times,
and then change my health,
“hello” is only printed one time,

it should print 3 times,
because i died 3 times, so the event has to be registered 3 times.

but it prints one time, why is that?

From what I remember they do get cleaned up. You can test this by just connecting a handler to .Destroying on the character and see if it fires.

You can use Humanoid.HealthChanged btw

1 Like

Yes!
I saw that the .Destroying Event fired when I respawn.

So that means that the Humanoid.HealthChanged function is being cleaned up,
and a new one is created. When the Character Respawns.
Is that right?

I also changed it to Humanoid.HealthChanged

1 Like

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