Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

When the brick hits 0 health it doesn't change the anchored to false?

Asked by
iuclds 720 Moderation Voter
4 years ago
Edited 4 years ago

the script is

while true do
    wait(.001)
if script.Parent.Parent.Humanoid.HealthChanged then
    script.Parent.Anchored = false
end
end

and inside explorer it looks like

Model ( parent )
Humanoid
Part?? ( parent )
script
0
How are you dealing the damage to humanoid sheepposu 561 — 4y
0
Also, if the if statement isn't in a while loop, then it won't continue to check sheepposu 561 — 4y
0
changed but still not working iuclds 720 — 4y
0
try if script.Parent.Parent.Humanoid.Health < (whatever health it is here) then and see if that works ik it might be a bit older method but it should work kom297 -4 — 4y

1 answer

Log in to vote
2
Answered by 4 years ago
Edited 4 years ago

Incorrect usage of events.

You don't use events in if statements because they aren't conditions nor can they be used as conditions. Same reason why you don't use them in repeat and while loops.

Compare the Humanoid's Health value to 0 through a HealthChanged function:

script.Parent.Parent.Humanoid.HealthChanged:Connect(function(newHealth)
    if newHealth == 0 then
        script.Parent.Anchored = false
    end
end)

When HealthChanged fires, it passes the new health value as its argument. Compare that value to 0 and you've got yourself a fully functional conditional statement.

Ad

Answer this question