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

Breaking door when Humanoid.health <= 0 not working,help?

Asked by 5 years ago

This question has been solved by the original poster.

I have a door model,and the doorknob haves Humanoid and the part of it is called "Head" ,the door part is called "Torso",So,the doorknob receives the damage correctly,but the door doesn't open,help!

while true do
    if script.Parent.Humanoid.Health <= 0 then
    script.Parent.Torso.CanCollide = false
    script.Parent.Torso.Transparency = 1
    script.Parent.Head.Transparency = 1
    script.Parent.Door2.CanCollide = true
    script.Parent.Door2.Transparency = 0
    script.Parent.Handle2.Transparency = 0
    end
end
3
You might want to look into event listeners. Also, this script should've crashed your studio. If you have an infinite or extremely extensive loop with no delay, studio will crash. User#25115 0 — 5y
0
phleg event listeners is just a complicated way to say event right? starmaq 1290 — 5y
0
oh nvm starmaq 1290 — 5y

2 answers

Log in to vote
0
Answered by
starmaq 1290 Moderation Voter
5 years ago

As Phlegethon said, this is not working, and you're studio is probarly crashing because your while loop is gonna be running and looping infinitly without a delay between each times it loops. So you gotta add a wait in your loop. Orrrrr you can make this way better by using the Died event, so there's no need to put it in a while loop cuz an event doesn't have to be looped, it can be called if something happens at any times, but of course not always. Always use the died event its useful and better than checking if health is == 0.

script.Parent.Died:Connect(function()
    script.Parent.Torso.CanCollide = false
    script.Parent.Torso.Transparency = 1
    script.Parent.Head.Transparency = 1
    script.Parent.Door2.CanCollide = true
    script.Parent.Door2.Transparency = 0
    script.Parent.Handle2.Transparency = 0
end)

Ad
Log in to vote
-3
Answered by 5 years ago
Edited 5 years ago

Easy peasy you just find the guy's health on zero and HULK SMASH the door open!

There is a Health property in Humanoid in Character.

if game.Workspace.YourUsernameHere.Humanoid.Health == 0 then door.Parent = nil end

Don't thank me, I don't want it.

Answer this question