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

How do i make players drop a part after they die?

I am making an FPS game and everything works fine at the moment but I want to add a feature that players drop 1 single model (or part) on death. I have the ammo box whit full scripts in it but I just need to know how to make players drop that part. The ammo box is a part I will change it to a model if that's better

id like information about all the things I need and where to exactly put them in order to do the right thing.

every answer will be appreciated (:

2 answers

✓ Accepted answer

First, insert that ammo box in "Replicated Storage". Now, insert this in a script in StarterPlayer > StarterCharacterScripts:

wait(5) -- waits for the player to load it

script.Parent.Humanoid.Died:Connect(function()
	local ClonedAmmoBox = game.ReplicatedStorage:WaitForChild("WHATEVER YOU NAMED YOUR AMMO BOX"):Clone()
	ClonedAmmoBox.Parent = game.Workspace
	ClonedAmmoBox.CFrame = CFrame.new(script.Parent:WaitForChild("HumanoidRootPart").Position)
end)

Also, make sure the ammo box is a part and not a model!

What I did is that when the player dies, the script clones the ammo box into the workspace. Then, I set the position of the cloned ammo box at the player's humanoid root part. You could also insert that ammo box in server storage, cuz this is a script and not a local script, but you will have to change the "ReplicatedStorage" at line 4 to "ServerStorage".

5 comments

0

Your script seems to be correct! But always be sure to explain everything you're doing, for example what's the .Died event, why was the part put in Replicated Storage and how did we copy it and positioned it there. ect.

0

ok

0

done

0

i got it already thank tough

0

no problem!

use this: (make sure to put it in StarterCharacterScripts) Put the thing you want them to drop in lighting and rename Handle to whatever you need

script.Parent = 
local Torso = script.Parent:FindFirstChild('Torso')
function onDied()
print ("Script Loaded.")
wait(1)
local n = game.Lighting["Handle"]:Clone()
	n.Parent = game.Workspace
	n.Position = Torso.Position
	n.Handle.Position = script.Parent.Torso.Position
	
end
while true do
	wait(0.00000001)
	if script.Parent.Humanoid.Health == 0 then
		
	onDied()
	end
	
end

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