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

How do i make an npc drop an item?

Hello. How do i make an npc like a zombie (R16) to have a chance or to be 100% sure that you will get an specific drop?

3 comments

0

code it and then it will magically drop

0

I dont know how to do it.

0

You can link a function to the Died() event of your NPC's humanoid. Then within that function you can spawn in the item you wish to drop. https://developer.roblox.com/api-reference/class/Humanoid

1 answer

A effective way to do it is by creating a folder with every items you wish to drop, or some folder with specific item in it.

After you need to make a script that when his Humanoid Parents is killed, he does a function to clone and move it to the last known NPC position.

local copy = game:GetService('Folder').Dummy.NPC:Clone(); 
copy.Parent = workspace
copy:MoveTo(workspace.SpawnPoint.Position)

You can try yo use this type of code up here to move the NPC or a cloned one if you ever wish to make it respawn. Or even do the same with the object but with a function before local, which can be whatever ways you want like: "while true do" and assign a true or false value on the NPC Humanoid life, like if his "Health" reach "0" than it is true.

Don't know if this will help but hope it will.

1 comment

0

Can you send me the script?

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