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

I need help with creating a script that makes NPC drops loot upon death ?

Hi all im very new to scripting and need to create a script that will make an NPC drop loot/items upon death. any help on this matter will be much appreciated. Thank you :)

3 comments

0

Sounds like a request to me. Make a connection to their humanoid's "Died" event, store whatever loot you want in ServerStorage, clone it and position its PrimaryPart.

0

Can you include the script / show us what you have tried

0

Thank you for the reply. i will post again when i get my head round this lol

1 answer

game:GetService('Players').PlayerAdded:connect(function(player)
	player.CharacterAdded:connect(function(character)
		character:WaitForChild("Humanoid").Died:connect(function()
			--//Write here what you want it to do. For example:
                        local loot = Instance.new("Part").Parent = workspace.Enemy.RightLeg --//Right leg is just an example it should create the block.
                        loot.BrickColor = BrickColor.new("Gold")
                        loot.Material = Enum.Material.Metal
		end)
	end)
end)

loot.Touched:connect(function(collect)
       player.leaderstats.Money.Value = player.leaderstats.Money.Value +50 --//Money is the currency type and the 50 is how much money/points you will get.
       wait(1.5)
       loot:Destroy()
end)

2 comments

0

Thank you so much for your time you spent on this ! havent got it to work yet but one more question, the NPC i have in "Players", how do i spawn them when game starts ?

0

Was ment to add your name to that last post, Thank you iiLevelMaker +rep

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