Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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

4 comments

0

How are you dealing the damage to humanoid

0

Also, if the if statement isn't in a while loop, then it won't continue to check

0

changed but still not working

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

1 answer

✓ Accepted answer

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.

This discussion is preserved as it was. New answers, comments, and votes are closed.