NPC coin dropping not working

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!

I Want To Make The NPC Drop 5 Coins When It Dies.

  1. What is the issue? Include screenshots / videos if possible!

The Script Is Inside The Dummy’s Humanoid And The Coin Is In Lightning Because It was instructed in the video to put it in lightning

  1. What solutions have you tried so far? Did you look for solutions on the Developer Hub?

I’ve Tried Watching Youtube But The Script Did Not Work.

After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!

function onDied()
	local Drop = game.Lighting("Coin"):Clone()
	Drop.Parent = game.Workspace


^ That is the script that was used on the video I watched and it doesn’t work for me

Edit: Its My First Time Posting On Forum :smiley:

1 Like

There are few errors here. This should work:

local function onDied()
	local Drop = game:GetService("Lighting"):WaitForChild("Coin"):Clone()
	Drop.Parent = game:GetService("Workspace")
	--I believe you want to destroy character here:
    for i, v in pairs(Character:GetChildren()) do --Replace Character with your character (it is probably script.Parent.Parent).
        if v:IsA("Part") or v:IsA("MeshPart") then

Humanoid.Died:Connect(onDied) --Replace Humanoid with your Humanoid.

Oh , Thank You Very Much! Ill Try The Script In A Bit :smiley:

1 Like

You can also set Drop’s position Drop.Position = script.Parent.Parent.HumanoidRootPart.Position. (if its part ofc)

Also as @Jermartynojm said, try to use in pairs to destroy every part in the character

1 Like

Oh Okay Thank You For The Help Too! :smiling_face_with_three_hearts:

1 Like

On a different note here, Lighting is not a canonical storage of objects. Consider either ReplicatedStorage or ServerStorage.

1 Like

Oh , Thanks For The Little Info! :smiling_face_with_three_hearts: