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

Humanoid Health and if statements?

Asked by 10 years ago

Hi I want to know why this script doesn't work?!

H = script.Parent.Humanoid.Health
if H == 0 then
    game.ReplicatedStorage.Iron:clone().Parent = script.Parent
    script.Parent.Iron.Postion = script.Parent.Torso.Poition
end

I have a zombie and when you kill it a brick is put into Workspace from replicated storage and its position is the zombies torso

Doesnt work tho plz herlp

0
One problem is the Iron parent is set to the Zombie character, which is deleted after it dies. Make game.ReplicatedStorage.Iron:clone().Parent = script.Parent to say game.ReplicatedStorage.Iron:clone().Parent = script.Parent.Parent and see what happens. XanthicDragon 38 — 10y
0
ok SirKitten2000 0 — 10y
0
thanks SirKitten2000 0 — 10y

1 answer

Log in to vote
1
Answered by
nate890 495 Moderation Voter
10 years ago

Use the Died event to determine when the zombie dies.

local zombie = script.Parent
local H = zombie.Humanoid

H.Died:connect(function()
    local iron = game.ReplicatedStorage.Iron:Clone() -- "clone" is deprecated so we avoid using it (no caps)
    iron.Parent = zombie
    iron.Postion = zombie.Torso.Poition
end)
Ad

Answer this question