[FIXED] Humanoid.HealthChanged is only working when the health value goes down

FINAL UPDATE so it seems that restarting Roblox Studio fixed the problem, weird.

I have a module called healthModule in ServerScriptService
and when a player dies or their health changes healthModule.SetStatus(player) is called.

How it’s supposed to work is if a player’s health goes under 15, platformstand them and set their player status to “injured”, if they die then set the status to “dead” and if they get healed, then platformstand is disabled and the status is cleared.

local currentStatus --this exists at the top of the module just wanna make sure I don't get it as a suggestion

function healthModule.setStatus(player)
	local character = player.Character
	if character.Humanoid.Health <= 15 then
		if character.Humanoid.Health > 0 then
			currentInteraction = createInteraction(character.Torso, "e", "stompOut", "Stomp Out", false)
			character.Humanoid.PlatformStand = true
			currentStatus = createStatus(character)
			currentStatus.Frame.TEXT.Text = "*PLAYER IS SERIOUSLY HURT*"
			return "injured"
		end
	end
	if character.Humanoid.Health > 15 then
		if character.Humanoid.PlatformStand == true then character.Humanoid.PlatformStand = false end
		if currentStatus ~= nil then currentStatus:Destroy() end
		if currentInteraction ~= nil then currentInteraction:Destroy() end
		return "normal"
	end
	if character.Humanoid.Health == 0 then
		if currentStatus ~= nil then currentStatus:Destroy() end
		if currentInteraction ~= nil then currentInteraction:Destroy() end
		currentStatus = createStatus(character)
		currentStatus.Frame.TEXT.Text = "*PLAYER IS DEAD*"
		return "dead"
	end
end

When a player gets healed, the if statement that returns “normal” doesn’t run.

Any ideas as to what the issue is?

quick edit: setStatus is called every time the the humanoid.healthchanged event fires (id also like to clarify that there’s no errors in the dev console when the issue happens)

heres a video:

another edit:

Alright, whenever setStatus is called the health will print:
image
It seems that setStatus isn’t called when the health gets set to a higher number.
However, setStatus is called everytime the Humanoid.HealthChanged event is fired.

2 Likes