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)
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.
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.
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.