Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by
n_ubo 29
5 years ago
Edited 5 years ago

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

Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

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".

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. starmaq 1290 — 5y
0
ok TheRealPotatoChips 793 — 5y
0
done TheRealPotatoChips 793 — 5y
0
i got it already thank tough n_ubo 29 — 5y
0
no problem! TheRealPotatoChips 793 — 5y
Ad
Log in to vote
0
Answered by 4 years ago

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

Answer this question