hello everyone
i am creating a game where u need to kill npc for currency, so i want the npc to drop a coin that i have coded but i dont know how i can let the npc dron anything
Make a script and write this:
local Humanoid = script.parent:WaitForChild(“Humanoid”)
Humanoid.Died:Connect(function()
local item = (item’s location):Clone()
item.Parent = game.workspace
item.Handle.Position = script.parent.HumanoidRootPart.Position
end)
where do i need to put the item
ServerStorage or ReplicatedStorage
and what do you mean with item’s location
example that u want a sword to drop when NPC dies
at the items variable write :
local item = game.ServerStorage.Sword:Clone()
like this?
local Humanoid = script.parent:WaitForChild(“Humanoid”)
Humanoid.Died:Connect(function()
local item = game.ServerStorage.Coin:Clone()
item.Parent = game.workspace
item.Handle.Position = script.parent.HumanoidRootPart.Position
end)
this doesnt work for me
Does it show any errors?
or just doesn’t work?
it just does not do anything (text)
I’m sorry but if you’re just gonna copy the script, it won’t help you to achieve what you’re trying to do. Just try and understand the script by yourself.
Put the script inside of StarterCharacterScripts.
it does work, you just dont know any scripting and try to use the script without correcting anything in it, it should equal to your tools position, it perfectly works