How do you make a gun part appear on a players back when its unequipped and then reappear when its equipped

I am trying to write some code that would allow for my gun part to appear on my back when unequipped and appear normally when its equipped but whenever I tried welding the gun part to the players torso it didn’t appear on the players back at all, and nothing happened but the handle still worked.

	local A37 = serverstorage["A-37X"]
	local EK = serverstorage["E-K4"]
	local clonedtool = A37:Clone()
	local clonedtool2 = EK:Clone()
	local clonedtoolonback = A37:Clone()
	clonedtool.Parent = player.Backpack
	clonedtool2.Parent = player.Backpack
	if clonedtool.Equipped == false then
		clonedtool.Position = Vector3.new(player.Character.Torso.Position)
		local weld = Instance.new("WeldConstraint")
		weld.Parent = clonedtoolonback
		weld.Part0 = clonedtool.Handle
		weld.Part1 = player.Character.Torso
	end
  • Make sure all parts in the gun are welded to the primary part, most likely the handle in this case
  • Check to see if the part is going into the workspace
  • If the part is being cloned properly, figure out where it is
  • If the weapon isn’t quite on the back right, make an offset and tweak until it looks good.

I’ve achieved something like this before

			local weaponsname = player.PlayerGui.EquippedFrame.Frame.SelectionFrame.Primary.TextLabel.Text
			local weapon = game.ReplicatedStorage:FindFirstChild(weaponsname)
			Cooldown = true
			ViewmodelInCamera = true
			local NewViewmodel = Viewmodel:Clone()
			local NewWeapon = weapon:Clone()
			NewWeapon.Parent = NewViewmodel
			NewViewmodel.Parent = Camera
			NewViewmodel.Name = "Viewmodel"
			local Weld = Instance.new("Motor6D")
			Weld.Name = "HandleWeld"
			Weld.Part0 = NewViewmodel.Main
			Weld.Part1 = NewWeapon.Handle
			local weldOffset = ItemData.Offsets[Primary].Client
			Weld.C0 = CFrame.new(weldOffset.Position) * weldOffset.Rotation
			Weld.Parent = NewViewmodel.Main

			local ProxPrompt = NewViewmodel[Primary].Handle:FindFirstChild("ProximityPrompt")
			ProxPrompt:Destroy()

No matter what I do the gun still seems to appear lodged in my chest. I am not sure how to approach weldOffset either.

clonedtool.Unequipped:Connect(function()
		print("test")
		clonedtoolonback.Parent = game.Workspace
		clonedtoolonback.Name = "clonedtoolonback"
		clonedtoolonback.Model.PrimaryPart.CFrame = CFrame.new(player.Character.Torso.Position.X + 0.715, player.Character.Torso.Position.Y + -0.353, player.Character.Torso.Position.Z + -0.69)
		clonedtoolonback.Model.PrimaryPart.Orientation = Vector3.new(-40, -90, -0)
		local weld = Instance.new("WeldConstraint")
		weld.Parent = clonedtoolonback
		weld.Part0 = clonedtoolonback.Handle 
		weld.Part1 = player.Character.Torso
	end)```

Sorry for the delay, the weapon will be welded to the chest as that is where the constraint is being made, this is where our offset comes in, below is the image of the offset I use for my weapon, each weapon may differ depending on where you want it positioned on the back.

This is in a modulescript I’m using called ItemData

The only difference that could arise is how you are using a weld constraint whilst I’m using a motor6d, but I am mainly using motor6d’s as I animated the weapons

I found a different method while reading some documents, I made an accessory and made a BodyBackAttachment and just adjusted it, and it works now.

2 Likes

Only reason I didn’t go with that method was due to needing multiple different welding points, and wanted it to all be modular. That method is good though without having to make multiple attachments