How to make tool appear on player's back when unequiped?

Hey,
The title says almost all, I want player to wear tool on his back when the tool is unequiped and disappear when it’s equipped like in Isle:

In my case, the tool is in StarterPack folder so it’s given to all players automatically:
theTool

The Detector model contains all other mesh parts which is the tool made of and all of them are welded to Handle, “Working” is a sound that plays when the tool is on.

I don’t know what should I use to do it, I’ve never messed up with avatars in that way before. Can someone help me?

1 Like

All tools that are unequipped are stored in the backpack game.Players.PLAYERNAME.Backpack. So you can loop through all the tools and create a clone and weld them to the back of the player in some folder.

1 Like

Oooor simply create a model already on the back of the player and when the tool it’s unequipped make it visible?

2 Likes

That could potentially cause lag due to all the Instances Around 1 object.

1 Like

Eeeeeeffectively you’re right I didn’t thought of that

1 Like

you can weld it when you unequip it by using “Attachment” classes.

Or you can make an accessory with a script that functions when you unequip the item, the accessory clones itself from a random directory to the players back, including some CFrames

1 Like

Can you guys give an example in code? From what you said I can only create something like this:

local character = SerumDetector.Parent.Parent.Character

SerumDetector.Handle.Parent = character 
DetectorHandle.Parent = character
DetectorHandle.CFrame = character.HumanoidRootPart.CFrame

SerumDetector.Unequipped:Connect(function()
	local character = SerumDetector.Parent.Parent.Character
	
	SerumDetector.Handle.Parent = character 
	DetectorHandle.Parent = character
	DetectorHandle.CFrame = character.HumanoidRootPart.CFrame
	
end)

SerumDetector.Equipped:Connect(function()
	local character = SerumDetector.Parent

	character.Handle.Parent = SerumDetector
	DetectorHandle.Parent = SerumDetector
end)

It is not working

The best way to do it would be to create an accessory using your sword mesh (in studio not with a script of course), and store it inside the replicated storage, then within the tool unequiped function you just have to clone it and put it in your character.

Stop telling me how simple it is and just go ahead, I don’t want to guess what are you thinking about, that’s not the reason why I created this topic.

You don’t have to guess lol, I just gived you a solution.

  • Create your sword accessory in the studio, using the right body part attachment and change his position / orientation to be how you want it to be in character back.
  • store the accessory in the replicated storage.
  • With a script in your tool, use tool unequiped function to clone it and put it in your character.
  • in this same script, use tool equiped function to destroy the accessory.

Additionally to this, you’re also able to play a character animation which make the character take/store the sword in his back to make it more realistic if you want to… that’s up to you ^^

This is not a mesh but a model with a root part which is welded to all other parts and when I’m putting it in an accessory class it looks like this:


All welds are inactive. Root is the primary part of the model.

1 Like

You can put all the alternative welded parts inside the main part, then weld doesn’t get disabled.

I know you are not supposed to put parts inside another part as there is a small chance a part is not rendered but it is a risk we have to take as there is no other solutions unless you want to do an accessory for each part which will be a nightmare to do.

Anyway I link you an old tutorial that explain how to do it if you want to.

robloxapp-20230210-2005241.wmv (3.4 MB)
Is this a result you would want?

1 Like

Yes that’s exactly what I want to achieve

toolbackmodel.rbxl (32.2 KB)
You can use the code from this place that I made, but the summary is that when the tool is unequipped, the script creates a model and clones the tool. The script loops through the contents of the tool and puts the BaseParts, UnionOperations, and the MeshParts in the model. We then set the model’s PrimaryPart to be the Handle of the tool. The script then creates a new Weld parented to the Torso/UpperTorso. and sets the Part0 property to the torso and the Part1 property to the model’s PrimaryPart. We can then change the C1 property of the weld to change how the tool will appear on the player’s back.

When the tool is equipped, we destroy the weld and the model that was placed on the player’s back.

local Tool = script.Parent

local Character = Tool.Parent.Parent.Character or Tool.Parent.Parent.CharacterAdded:Wait()
local Torso = Character:FindFirstChild("UpperTorso") or Character:WaitForChild("UpperTorso")
Tool.Equipped:Connect(function()
	-- Loops through the children of the character's Torso and destroys the ToolBackModel and the Weld
	for Index, Child in pairs(Torso:GetChildren()) do
		if Child:IsA("Model") and Child.Name == "ToolBackModel" then
			Child:Destroy()
		end
		
		if Child:IsA("Weld") and Child.Name == "ToolBackWeld" then
			Child:Destroy()
		end
	end
end)

Tool.Unequipped:Connect(function()
	-- Create a model called "ToolBackModel" and clone the tool
	local ToolClone = Tool:Clone()
	local ToolBackModel = Instance.new("Model")
	ToolBackModel.Parent = Torso
	ToolBackModel.Name = "ToolBackModel"
	
	-- Loops through the contents of the Tool Clone and puts them into the ToolBackModel
	for Index, Child in pairs(ToolClone:GetChildren()) do
		if Child:IsA("BasePart") or Child:IsA("MeshPart") or Child:IsA("UnionOperation") then
			Child.Parent = ToolBackModel
			-- Sets the child's CanCollide and Massless properties so they don't add mass to the player or interfere with collisions
			Child.CanCollide = false
			Child.Massless = true
		end
	end
	
	-- Sets the PrimaryPart to the Tool's handle
	ToolBackModel.PrimaryPart = ToolBackModel:FindFirstChild("Handle")
	-- Creates the Weld
	local ToolBackWeld = Instance.new("Weld")
	ToolBackWeld.Name = "ToolBackWeld"
	-- Parents the weld to the torso so it can be destroyed when the tool is equipped
	ToolBackWeld.Parent = Torso
	-- Welds the tool model to the torso
	ToolBackWeld.Part0 = Torso
	ToolBackWeld.Part1 = ToolBackModel:FindFirstChild("Handle")
	-- Change the C1 property to change how the tool model will appear on the player's back
	ToolBackWeld.C1 = CFrame.new(0.077, 0.036, -0.6) * CFrame.Angles(0, 0, math.rad(50)) --  Be sure to use math.rad() for CFrame.Angles() since it uses radians not degrees
end)
2 Likes

Sorry for late respond but it didn’t work and I tried to fix it but nothing worked, model and weld didn’t even show up inside UpperTorso

Is there an issue with just cloning the handle and welding it to the player’s back?

I used the script @GooberOnTheForums sent, inserted it to my tool but it didn’t work and nothing appeared inside the UpperTorso

I would normally recommend attempting to write the script yourself to better understand it, rather than just copying somebody else’s code. With that said, here’s a script you can put in ServerScriptService:

local players = game:GetService('Players')

players.PlayerAdded:Connect(function(player)
	local itemAdded = player.DescendantAdded:Connect(function(tool)
		if tool:IsA('Tool') then
			local handle = tool:WaitForChild('Handle'):Clone()
			handle.Name = tool.Name
			local backPosition = tool:GetAttribute('BackPosition') or Vector3.new(0,0.25,0.55)
			local backOrientation = tool:GetAttribute('BackOrientation') or Vector3.new(90,-22.5,0)
			while not player.Character do task.wait() end
			handle.Parent = player.Character
			local weld = Instance.new('Weld',handle)
			weld.Part1 = handle
			repeat
				local torso = player.Character:FindFirstChild('Torso')
				if torso then
					weld.Part0 = torso
					torso = nil
				else
					torso = player.Character:FindFirstChild('UpperTorso')
					if torso then
						weld.Part0 = torso
						torso = nil
					end
				end
				if weld.Active then
					break
				end
				task.wait()
			until false
			weld.C0 = CFrame.new(backPosition)*CFrame.Angles(math.rad(backOrientation.X),math.rad(backOrientation.Y),math.rad(backOrientation.Z))
			weld = nil
			local leavingBackpack
			leavingBackpack = tool:GetPropertyChangedSignal('Parent'):Connect(function()
				if not tool.Parent then
					leavingBackpack:Disconnect()
					leavingBackpack = nil
					tool = nil
					handle = nil
					backPosition = nil
					backOrientation = nil
				elseif tool.Parent ~= player.Backpack then
					task.wait()
					handle:Destroy()
				end
			end)
		end
	end)
	local leaving
	leaving = players.PlayerRemoving:Connect(function(plr)
		if plr == player then
			itemAdded:Disconnect()
			itemAdded = nil
			leaving:Disconnect()
			leaving = nil
		end
	end)
end)

I set the defaults to work with the classic sword tool, but you can customize the offsets by adding the following attributes to your tool and adjusting them that way:

image

I’ll quickly add down here about why this script is a bit more complicated than it should be. For one, Backpack.ChildAdded just doesn’t work because apparently the first loaded Backpack becomes nil and is replaced. I then also had to add a repeat loop because when a tool is added too quickly, it just doesn’t attach properly. The loop only executes once, which makes no sense as to why it doesn’t just set directly, but here we are I guess. Took me way longer than it should’ve due to these weird Roblox bugs.

It doesn’t work and I have no idea how to fix it because the code is totally not in my style and there are no errors in the output