how would i create a npc that when it dies, summons an items that spawns on them? been trying to script this for a while now, here is my current script:
01 | while true do |
02 | wait() |
03 | if script.Parent.Humanoid.Health = = "0" then |
04 | Mod = game.ServerStorage.Lvl 1 Reward |
05 | clone = Mod:clone() |
06 | clone.Parent = workspace |
07 | clone.Position = CFrame.new(script.Parent.Head) |
08 | clone:MakeJoints() |
09 | script.Parent:Destroy() |
10 | end |
11 | end |
The Script Doesnt Seem To Work, as it wont summon the item on the npc when it dies. If any of you guys know how to fix this, PLEASE HELP ME!
01 | function RewardItem(Level) |
02 | local npc = script.Parent |
03 | if Level = = 1 then |
04 | local mod = game.ServerStorage [ "Lvl1Reward" ] :Clone() |
05 | mod.Parent = workspace |
06 | mod.Position = script.Parent.Head.Position |
07 | mod:MakeJoints() |
08 | print ( 'Success, destroying...' ) |
09 | npc:Destroy() |
10 | elseif Level = = 2 then |
11 | local mod 2 = game.ServerStorage [ "Lvl2Reward" ] :Clone() |
12 | mod 2. Parent = workspace |
13 | mod 2. Position = script.Parent.Head.Position |
14 | mod 2 :MakeJoints() |
15 | print ( 'Success, destroying...' ) |