How do I make it so that my Bank vault's head part un-anchors when the health is on 0. I've had multiple attempts on doing this and still no luck.
This is the explorer:
Workspace> BankVault>Humanoid, script, Head>Smoke, Part, Part, Part, Part, Part
BankVault is a model, Head is a part which has other parts inside of it, there's smoke particles because i made it so that if the health is under half of the original health, there would be smoke particles. "script" is the script I'm trying to make to cause this to function:
local hum = script.Parent.Humanoid hum.HealthChanged:connect(function(health) if hum.Health == 0 then game.Workspace.BankVault.Head.Anchored = false wait(5) game.Workspace.BankVault.Head.Visible = false end end)
Much appreciated if you help :)
-c_omb
According to your code, Head should be a Part
but Parts don't have a property named Visible
, you should change it to this.
local hum = script.Parent.Humanoid hum.HealthChanged:Connect(function(health) if hum.Health <= 0 then game.Workspace.BankVault.Head.Anchored = false wait(5) game.Workspace.BankVault.Head.Transparency = 1 game.Workspace.BankVault.Head.CanCollide = false end end)
The code above detects if the Humanoid health is smaller or equals to 0. If it is, unanchors the Head and makes it transparent and be able to walk through.
Edit: connect
is deprecated, use Connect
instead.