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

Humanoid Health and if statements?

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

3 comments

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.

0

ok

0

thanks

1 answer

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)

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