Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local dropChance = 20 -- out of 100, 0 being no chance, 100 being every time
- local npc = script.Parent
- local toDrop = script.ItemName -- what item the script gives npc's killer
- local human = npc.Humanoid
- -------------------------------------------------------
- function giveItem(p)
- local chance = math.random(1,100)
- if chance <= dropChance then
- print("NPC died, dropped " ..toDrop.Name.. " which was picked up by " ..p.Name)
- local c = toDrop:Clone()
- c.Parent = p.StarterGear
- else
- print("NPC died, did not drop anything")
- end
- end
- human.Died:connect(function()
- local tag = human:FindFirstChild("killer")
- if tag then
- local p = tag.Value
- if p then
- giveItem(p)
- end
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement