Attempt to index number with 'GetPropertyChangedSignal'?

I have a script that creates an IntValue with the name “heart” on the player as soon as it enters.

The problem is that it generates an error: “attempt to index number with ‘GetPropertyChangedSignal’”. Until I could use the “Changed” event, however I would like to use “GetPropertyChangedSignal” to be more practical.

Can anyone help?

script:

game.Players.PlayerAdded:Connect(function(plr)
	
	local leader = Instance.new("Folder",plr)
	leader.Name = "PlayerInfo"
	
	local Healthvalue = Instance.new("IntValue",leader)
	Healthvalue.Name = "Heart"
	Healthvalue = 5
	
	Healthvalue:GetPropertyChangedSignal("Value"):Connect(function()
	print("ALTEREED")
	if Healthvalue == 0 then
		plr.Character:WaitForChild("Humanoid").Health = 0
	end
								
	end)
end)

You are setting Healthvalue to 5 on the line above. Try (as @Operatik said below) this:
Healthvalue.Value = 5 instead.

Also, for BaseValue objects, you can use the .Changed event instead of GetPropertyChangedSignal

1 Like

Healthvalue = 5

This is a mistake, you accidentally shadowed the variable, overwriting Healthvalue into a number. It should be:

Healthvalue.Value = 5

1 Like

Oh didn’t see your post, sorry