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

Dropping backpack on death / Positioning them to the character's HumanoidRootPart Position?

This is what I tried to make but failed:

--I located the character so no worries.

char.Humanoid.Died:connect(function()
	local plr = game.Players:GetPlayerFromCharacter(char)
	for i,v in pairs(plr.Backpack:GetChildren()) do
		v.Handle.Position = char.HumanoidRootPart.Position --Sad face
		v.Parent = workspace
	end
end)

The thing here is that I want the player to drop everything he/she has in their backpack. But Positioning the Handle won't help. Neither is positioning the whole tool because there is no function for that. Any help?

2 answers

✓ Accepted answer

I’m not sure if there is a simpler way, but you could try putting each tool inside a model that you position at the character, and then moving the tool back outside the model once it’s been positioned.

char:WaitForChild("Humanoid").Died:Connect(function()
	local plr = game.Players:GetPlayerFromCharacter(char)
	for _,tool in pairs(plr.Backpack:GetChildren()) do
		if tool:IsA("Tool") and tool:FindFirstChild("Handle") then
			local positionModel = Instance.new("Model")
			tool.Parent = positionModel
			positionModel.PrimaryPart = tool.Handle
			positionModel:MoveTo(char.HumanoidRootPart.Position)
			tool.Parent = workspace
			positionModel:Destroy()
			-- re-welding my be required here
		end
	end
end)

I've found a really nice way to do it on my own.

But thanks for the help! I'll accept your answer

1 comment

0

I'd be interested in what your way involves

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