How do I make tools appear around the HumanoidRootPart when the player is dead

I am trying to currently make a system where if the player dies the tools in their Backpack and Character appear so other players can use these tools.

I coded the Backpack Tools and stuff getting a new parent (workspace.DroppedItems) but I didnt code it to spawn around the player and I tried doing it but nothing worked…

And also I want it to not spawn inside the player’s humanoid root part. It should drop just in like the game “DOORS”

How will I do this?

  • First you would need to check how many items will be dropped so you can calculate the space between each item.
local amountofitems = #items
local range = 5 -- amount of studs it will spawn offset from the player
  • Then you can calculate the position based on the amount of items using sine or cosine.
local amountofitems = #items
local range = 5 -- amount of studs it will spawn offset from the player

for i, item in pairs(items) do
	local degrees = i * amountofitems / 360
	local radians = degrees * math.pi / 180 -- math.sin and math.cos work with radians not degrees
	
	local position = Vector3.new(math.sin(radians) * range, player.Character.PrimaryPart.Position.Y, math.cos(radians) * range) + player.Character.PrimaryPart.Position
end

This should work. You might have to change it here and there to your likings.

1 Like