How to make ALL tools drop on death?

I want the player with the tool to drop there tool when they die.

When i though how i was going to script this my mind was empty. I need ALL tools in player backpack to drop when player dies.

3.Different from Make specific tool drop on death I want all tools to just drop at once.

7 Likes

Put this script in serverscriptservice.

game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function()
wait()
player.Character:WaitForChild("Humanoid").Died:Connect(function()
for i,v in pairs(player.Backpack:GetChildren()) do
v.Parent = workspace
v:MoveTo(player.Character:GetPrimaryPartCFrame().p)
end

for i,v in pairs(player.Character:GetChildren()) do
if v:IsA("Tool") then
v.Parent = workspace
v:MoveTo(player.Character:GetPrimaryPartCFrame().p)
end
end
end)
end)
end)

tell me if i got anything wrong, this was made in the websites script editor

3 Likes

You can use the :GetChildren() function, and then run a for loop that iterates through each child (GetChildren function returns a table) of the Backpack and drops it.

Edit: You’d probably have to set the CFrame of the handle to a position near the character, as well. This post could help you with that.

Can’t you just for loop to workspace?

1 Like

Even though if a changed the position of the tool it would still be in backpack.

This does not work. (30 Characters)

Error, please? I cannot fix it without the error.

You would need to change the CFrame (if you change the position welds might break if you have any), and also set the parent to workspace.


player.CharacterAdded:Connect(function()

wait()

player.Character:WaitForChild("Humanoid").Died:Connect(function()

for i,v in pairs(player.Backpack:GetChildren()) do

v.Parent = workspace

v.Handle.Anchored = true

v.Handle.CanCollide = true

v.Handle.CFrame = CFrame.new(player.Character.PrimaryPart.CFrame * Vector3.new(math.random(1,5),3,3))

wait(0.2)

v.Handle.Anchored = false

end

for i,v in pairs(player.Character:GetChildren()) do

if v:IsA("Tool") then

v.Parent = workspace

v.Handle.CanCollide = true

v.Handle.CFrame = CFrame.new(player.Character.PrimaryPart.CFrame * Vector3.new(math.random(1,5),3,3))

wait(0.2)

v.Handle.Anchored = false

end

end

end)

end)

end)```

It works but i got another problem. When the player dies… Character Parts touches the tool and the same thing happens. Would there be a way to make the tool drop 10-20 studs away from the player?

You just have to set the range to 10-20…

game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function()
wait()
player.Character:WaitForChild("Humanoid").Died:Connect(function()
for i,v in pairs(player.Backpack:GetChildren()) do
	
v.Parent = workspace
v.Handle.Anchored = true
v.Handle.CanCollide = true
v.Handle.CFrame = CFrame.new(player.Character.PrimaryPart.CFrame * Vector3.new(math.random(10,20),3,3))
wait(0.2)
v.Handle.Anchored = false

end

for i,v in pairs(player.Character:GetChildren()) do
if v:IsA("Tool") then
v.Parent = workspace
v.Handle.CanCollide = true
v.Handle.CFrame = CFrame.new(player.Character.PrimaryPart.CFrame * Vector3.new(math.random(10,20),3,3))
wait(0.2)
v.Handle.Anchored = false
end
end
end)
end)
end)

8 Likes

This works!!! Thank you so much!

2 Likes

This is just what i needed. Is there a way to edit this script to make the tools disappear after 30 seconds if nobody picks them up?

Bro really bumped a post for 3 years ago.

1 Like

You could create a seperate script which regularly deletes all objects found in the workspace with a ClassName == “Tool”.

(I imagine this information is probably useless to you by now, but I’d rather post it for anyone who happens to be interested after scrolling through this thread.)

good idea, but better is to create a function and wait 30 seconds and then remove the tools, you can use Task.wait or Task.Delay you see. edit: it is better to do it in the script itself to know which tools have not been grabbed in an optimized way.

Debris Service is what you should use.