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

My working bank vault with health wont function?

Asked by
c_omb 0
3 years ago

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

0
Any errors in output? NotTheChara 191 — 3y
0
No errors. c_omb 0 — 3y

1 answer

Log in to vote
0
Answered by 3 years ago
Edited 3 years ago

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.

0
Btw, the part will fall and be destroyed. If you don't wish to do that, change the BankVault Parent to somewhere else. NotTheChara 191 — 3y
0
Alright, thanks so much @NotTheChara c_omb 0 — 3y
0
Also, I'll do it tomorrow and give feedback since right now I'm on phone c_omb 0 — 3y
0
If you're going to refer to the BankVault Object several times, make a variable.... Ziffixture 6913 — 3y
View all comments (2 more)
0
@Zuffixture Okay thanks c_omb 0 — 3y
0
@NotTheChara sorry for the late response, but the script you sent does not work. I'll figure it out soon anyway, and thanks! c_omb 0 — 3y
Ad

Answer this question