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

My working bank vault with health wont function?

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

2 comments

0

Any errors in output?

0

No errors.

1 answer

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.

6 comments

0

Btw, the part will fall and be destroyed. If you don't wish to do that, change the BankVault Parent to somewhere else.

0

Alright, thanks so much @NotTheChara

0

Also, I'll do it tomorrow and give feedback since right now I'm on phone

0

If you're going to refer to the BankVault Object several times, make a variable....

0

@Zuffixture Okay thanks

0

@NotTheChara sorry for the late response, but the script you sent does not work. I'll figure it out soon anyway, and thanks!

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