function Monster:IsAlive()
return Self:FindFirstChild(“Humanoid”).Health > 0 and Self:FindFirstChild(“Humanoid”).Torso ~= nil
end
Beside of that, you didn’t put ‘if’ and ‘then’, it should be:
function Monster:IsAlive()
return if Self:FindFirstChild(“Humanoid”).Health > 0 and Self:FindFirstChild(“Humanoid”).Torso ~= nil then
end
end
Not really it does the same thing.
local a = true
local b = "second"
local x = a and b or "wrong"
if a then
print(b)
else
print("wrong")
end
@NOOBHQ100K I think you should use self
with lowercased s
Whenever you get an error like this, it’s basically saying that whatever you’re trying to access .Health on doesn’t exist yet. In this case, it means the Humanoid.
Chances are it’s not loaded in yet when this function runs. If this is the case, you can simply change :FindFirstChild() to :WaitForChild().
Also, on an unrelated note, the Torso is not inside the Humanoid, but instead inside the Character (which appears to be referred to as ‘Self’ in this case).
function Monster:IsAlive()
return Self:WaitFirstChild("Humanoid").Health > 0 and Self:WaitFirstChild("Torso") ~= nil
end
If you get infinite yield warnings then these instances haven’t been correctly defined/referenced.
Can you describe what the variable Self
is? It should be the monster character model.
self is a dummy , not a player