Backpack not working properly

Hello everyone,
I am making it so when you unequip a tool this runs, but the tool doesn’t move with the player and just spawns and falls through the ground.

		local Trampoline = Trampolines[Data.Trampoline.Value]:Clone()
		Trampoline.Name = 'Trampoline'
		Trampoline.PrimaryPart.Name = "Handle"

		for _, part in Trampoline:GetChildren() do
			if part:IsA("BasePart") then
				part.CanCollide = false
				part.CFrame = part.CFrame * CFrame.Angles(0, math.rad(90), 0)
			end
		end
		
		local handle = Trampoline.Handle
		for _, part in ipairs(Trampoline:GetChildren()) do
			if part:IsA("BasePart") and part ~= handle then
				local wc = Instance.new("WeldConstraint")
				wc.Part0 = handle
				wc.Part1 = part
				wc.Parent = handle
			end
		end
		
		local Attachment = Instance.new('Attachment')
		Attachment.Name = 'BodyBackAttachment'
		Attachment.Parent = Trampoline.Handle
		Attachment.Position = Vector3.new(0, 0, 0)
		
		local Accessory = Instance.new('Accessory')
		Accessory.Name = 'Backbling Trampoline'
		Trampoline.Parent = Accessory
		
		Accessory.Parent = Character
		
		local Humanoid = Character.Humanoid
		if Humanoid then
			Humanoid:AddAccessory(Accessory)
		end
1 Like

Is this what you’re trying to achieve?

Video:

2 Likes

I made this a while back but added comments for you.

Hierarchy:

Screenshot 2025-04-25 192343
Screenshot 2025-04-25 192413
Screenshot 2025-04-25 192430

add the attributes in the tool

ToolHandler:

local ToolHandlerModule = require(game.ServerScriptService:WaitForChild("ToolHandler"):WaitForChild("ToolModule"))
ToolHandlerModule.connectAllPlayers()

ToolModule:

local ToolHandlerModule = {}

local players = game:GetService('Players')

-- this function handles when a player gets a tool added to their character
local function onItemAdded(player, tool)
	if tool:IsA('Tool') then
		-- clone the handle and grab the position and orientation attributes
		local handle = tool:WaitForChild('Handle'):Clone()
		handle.Name = tool.Name
		local backPosition = tool:GetAttribute('BackPosition')
		local backOrientation = tool:GetAttribute('BackOrientation')

		-- wait until the player's character is fully loaded
		repeat
			task.wait()
		until player.Character

		-- parent the handle to the character and create a weld
		handle.Parent = player.Character
		local weld = Instance.new('Weld')
		weld.Part1 = handle
		weld.Parent = handle

		-- attach the weld to the torso or upper torso
		local torso
		repeat
			torso = player.Character:FindFirstChild('Torso') or player.Character:FindFirstChild('UpperTorso')
			if torso then
				weld.Part0 = torso
				break
			end
			task.wait()
		until torso

		-- set the weld's position and orientation using the tool's attributes
		weld.C0 = CFrame.new(backPosition) * CFrame.Angles(math.rad(backOrientation.X), math.rad(backOrientation.Y), math.rad(backOrientation.Z))

		-- clean up when the tool is removed from the backpack
		local leavingBackpack
		leavingBackpack = tool:GetPropertyChangedSignal('Parent'):Connect(function()
			if not tool.Parent or tool.Parent ~= player.Backpack then
				handle:Destroy()
				leavingBackpack:Disconnect()
			end
		end)
	end
end

-- this function connects the tool handler to a specific player
function ToolHandlerModule.connectPlayer(player)
	-- listen for when the player adds a new tool
	local itemAddedConnection
	itemAddedConnection = player.DescendantAdded:Connect(function(descendant)
		if descendant:IsA('Tool') then
			onItemAdded(player, descendant)
		end
	end)

	-- disconnect event listeners when the player leaves
	local playerLeavingConnection
	playerLeavingConnection = players.PlayerRemoving:Connect(function(plr)
		if plr == player then
			itemAddedConnection:Disconnect()
			playerLeavingConnection:Disconnect()
		end
	end)
end

-- this function connects the tool handler to all players currently in the game
function ToolHandlerModule.connectAllPlayers()
	for _, player in pairs(players:GetPlayers()) do
		ToolHandlerModule.connectPlayer(player)
	end

	-- also listen for any new players joining
	players.PlayerAdded:Connect(ToolHandlerModule.connectPlayer)
end

return ToolHandlerModule

Let me know if this is what you wanted.

1 Like

Another example:

1 Like