Inside of a class Model which contains a Humanoid when the Humanoid is dead the Script doesn't detect it as dead and the Script class thinks the Human

I have a script that goes inside of a model, and the if function below always returns true even though the humanoid is dead and I have even checked, the health is below 0.

if C_Humanoid.Health>0 then
--this always return true no matter what!!
end

so I have literally no idea where I have gone wrong here because I read this over 10.56 times and yet nothing is wrong. The variables are correct and everything.

but wiat…

I print pass and it’s false when he dead… so …

task.spawn(function()
	while wait(1) do
		pcall(function()
			if Check() then
				local Found = GetHumanoidsSurrounding()

				if #Found>0 then
					for _,v in Found do
						v.Health-=25
					end
				end

			end
		end)

	end
end)

how is this loop still working?

1 Like

Where do you run this check? Try using a .HealthChanged event

blackbeard-writing

1 Like

this functiono

local function Check()
	local Pass = false
	
	if C_Humanoid.Health>0 and C_Humanoid:GetState()~=Enum.HumanoidStateType.Physics and C_Humanoid:GetState()~=Enum.HumanoidStateType.Dead then
		Pass = true
	end
	
	return Pass
end

Why Must It Be This Way? Even when the state is a physical does it returning a true value. BUT THE STATE, IS PHYSICALA!!! the Script should not be returning a true if the human is:

state physical,
dead,
state dead.

but it returns true, thinking this humanoid is a perfectly fine.

I could nota use a healtyhachanged because, it is a checko fucnion.

Hm… How about you pass me a more complete code so I can see when the function is being called?

1 Like
task.spawn(function()
	while wait(1) do
		pcall(function()
			if Check() then -- RIght here!!! Right ehre! it returneo a trueo.!
				local Found = GetHumanoidsSurrounding()

				if #Found>0 then
					for _,v in Found do
						v.Health-=25
					end
				end

			end
		end)

	end
end)

This is where I call the funcion to detect. If it returns true, then I go on with my code. But the character still damages even when dead, although it’s not supposed to.

1 Like

I’m so sorry, I have made a crucial mistake in my coding.

It seems that instead of using the task library, I have used the classic “wait.” I apologize for my inconvenience and I’m sorry for the lives I’ve ruined. This will not hapen again in the future.

I’ve just resorted to deleting the script when the humanoid dies

nevermind another script was interferring calling out takedmaage

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