Cant change Humanoids Health after its Health is 0

  1. What do you want to achieve? I want to change an NPCs health after its 0

  2. What is the issue? Whenever it “supposedly” sets to 80, it print 80 on the server. But on the server when viewing the Health, it still says 0 (this is a serverscript). And theres no errors in output or anything.

  3. What solutions have you tried so far? I tried using Humanoid:SetStateEnabled(Enum.HumanoidStateType.Dead, false) and turning off the EvaluateStateMachine property, but its still not working.

(EVERYTHING ELSE IN THE SCRIPT WORKS FINE)
I have only put the main part causing problems hear:

local Humanoid = script.Parent["Wither Storm Head"].Wither

Humanoid.HealthChanged:Connect(function(Health)
	if Health <= 0 and deb == false then
		deb = true
		DamagedAnim:Play()
		DamagedSound:Play()
		roarAnim:Play()
		Beam.Transparency = 1
		otherScript.Enabled = false
		decal.Transparency = 0

		for _, part in pairs(particleFX:GetDescendants()) do
			if part:IsA("ParticleEmitter") then
				part.Enabled = false
			end
		end
		
		for _, player in ipairs(Players:GetPlayers()) do
			local character = player.Character
			if character then
				local hum = character:FindFirstChild("Humanoid")
				if hum then
					local rootPart = character:FindFirstChild("HumanoidRootPart")
					if rootPart then
						local rocketBeam = rootPart:FindFirstChild("RocketBeam")
						if rocketBeam then
							rocketBeam:Destroy()
							hum.PlatformStand = false
						end
					end
				end
			end
		end
		
		StoppedEvent:FireAllClients()
		
		shootAtRandomPlayer()

		wait(40)

		DamagedAnim:Stop()
		Beam.Transparency = 0.8
		print(Health .. "HP")  -- Prints 0
		Health = 80  -- THIS IS WHERE THE ISSUE IS OCCURING
		task.wait()
		print(Health .. "HP") -- Prints 80 but is still 0 on the server despite this being a serverscript
		otherScript.Enabled = true
		decal.Transparency = 1

		for _, part in pairs(particleFX:GetDescendants()) do
			if part:IsA("ParticleEmitter") then
				part.Enabled = true
			end
		end

		deb = false
	end
end)
1 Like

Hello, this is a simple mistake and has a simple fix, you cannlt directly use “Health” you have to use Humanoid.Health. If this solution does not work then tell me.

i already tried that before and nothing changed

It’s not a bug, you simply can’t change Humanoid.Health after it reaches zero. The only way to do this is to clamp the health at something like 0.01 or 1. (Just above 0)

3 Likes

Oh, That’s something I didn’t know :sob: thanks for informing.

Yeah. Mainly because the character is dead, you can’t kill someone twice.

1 Like

Is there a way to set a minimum health?

Not really but you can by just clamping the health to 1 or 5 when the humanoid takes damage. Make sure to do this in your damaging scripts.

alr tyy ill use some Values to store hits instead

isn’t there a dead state where you can disable it instead.

Oops, almost forgot about that. Thanks for correcting me! But this method also works.

As i stated, i already tried using that before. It would print out that the NPC had 80 health, but when checking on the server it remained at 0, and any tool used on it would do nothing.