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

How can i clone a item to a dead humanoid?

Asked by
Shematics 117
5 years ago

Hi guys ive been working on a script inside of a NPC, his main purpose is to spawn a part in a folder using :Clone() and MoveTo. I have a folder inside ReplicatedStorage in which the item is in but they are more than 1 item so i made a random item picker. unfortunately, for a reason that i does not know, it does not work at all and shows nothing in the output. Am i missing something ?

Here's the code:

local humanoid = script.Parent.Humanoid

local alive = true

local health = humanoid.Health

local dead = health >0

local Object = game.ReplicatedStorage.Item

local die = false



function pick(part)

local children=Object:GetChildren()

local chosen=children[math.random(1,#children)]

local position = script.Parent.HumanoidRootPart.Position

local itemspawn = chosen:Clone()

itemspawn.Parent = game.Workspace

itemspawn:MoveTo(position)

if dead then alive = false

end

wait(.5)

pick(Object)

return chosen

end
0
Are you using the Humanoid.Died event? Rheines 661 — 5y
0
Yes, use the Humanoid.Died event. It tells you when the Humanoid's StateType has changed to Dead. DeceptiveCaster 3761 — 5y
0
Yeah like Rheines and MC said above, You're going to want to link it to the Humanoid.Died event. SnowFunsize 55 — 5y

Answer this question