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

Script Not Functioning Right! Npc OnDeath Summons Item?

Asked by 5 years ago
Edited 5 years ago

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:

01while true do
02    wait()
03    if script.Parent.Humanoid.Health == "0" then
04        Mod = game.ServerStorage.Lvl1Reward
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
11end

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!

1 answer

Log in to vote
0
Answered by
pingsock 111
5 years ago
Edited 5 years ago
01function 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 mod2 = game.ServerStorage["Lvl2Reward"]:Clone()
12        mod2.Parent = workspace
13        mod2.Position = script.Parent.Head.Position
14        mod2:MakeJoints()
15        print('Success, destroying...')
View all 22 lines...
0
okay, its amazing, however the script for 1. Doesnt need the if Level statements, its an npc that repspawns on death as well as the same thing. 2. for some reason the thing wont clone TheEmeraIdDev 22 — 5y
Ad

Answer this question