This line of code errored for the first time ever.
if result then
local hitPart = result.Instance
local character = hitPart:FindFirstAncestorWhichIsA("Model")
if character and character:FindFirstChild("Humanoid") then
if character.Humanoid.Health > 0 then -- this line errored
The output said: attempt to compare number < Instance
It looks like the error is coming from trying to compare a number and an object of type Instance. The comparison operator ‘>’ is not defined for comparing a number with an instance.
To fix this error, you may need to modify the code to make sure you are doing the correct comparison between the number and instance. For example, you could try casting the Health property to a number before doing the comparison, like this:
if character and character:FindFirstChild("Humanoid") then
if character.Humanoid.Health.Value > 0 then
This should make sure that you are comparing two numbers, and not trying to compare a number with an instance.
I rewrote it without the hitPart:FindFirstAncestorWhichIsA("Model")
I don’t know where I got that line from anyway.
if result then
local hitPart = result.Instance
if hitPart.Parent:FindFirstChild("Humanoid") then
character = hitPart.Parent
if character.Humanoid.Health > 0 then