PLEASE READ THE FULL POST, I MENTION SOMETHING AT THE BOTTOM!
I’m trying to make a health system for a game I’ve been making (aka. the Super Check Point parody if you’ve seen my last post) and I can’t quite seem to get the player to die after the HP value changes to 0. This is what I keep getting in the output:
This is the script I’m using:
wait(0.5)
local humanoid = script.Parent.Parent
while true do
if humanoid.HP.Value < 1 then
humanoid.Health = 0
wait(0.25)
end
end
I’m considering using a changed function, I’ll be trying it while I wait for replies. Thank you for reading!
That depends on how u want to do it. If u want to use Changed, u r free to do so, however if want to figure the error and possibly fix the script, i wud recommend reading the post.
It’s .Changed but yes, that will be a lot more efficient than running an infinite while true do loop waiting for a value to change.
local humanoid = script:FindFirstAncestorWhichIsA("Humanoid")
local hp = humanoid:WaitForChild("HP")
hp.Changed:Connect(function(new)
if math.round(new) <= 0 then
humanoid.Health = 0
task.wait(0.25)
end
end)