Putting A Part/Tool In Player's Other Hand When Holding Main Tool When Key is Pressed

I have a tool that when a key is pressed, another “tool” (or part) appears in their other hand with that hand raised. I have been unable to optimize this for quite a while now. Currently, I just set the part/tool as a part of the main tool, and set its transparency while also playing an animation to make it look like they’re holding it in their off-hand.

Can someone help me optimize this so that I don’t have to add the part/tool into each versions of the main tool? I am aware it works fine, but I want to optimize how it functions.

You can take a part and weld it to the left arm

Video
OtherHand.wmv (739.4 KB)

Left Arm Sword Script:


local tool = script.Parent

tool.Activated:Connect(function()
	local char = tool.Parent
	local LeftArm = char["Left Arm"]
	local RightArm = char["Right Arm"]
	local Motor6D = Instance.new("Motor6D")
	Motor6D.Name = "LeftGrip"
	Motor6D.Parent = LeftArm
	Motor6D.Part0 = LeftArm
	Motor6D.Part1 = tool.Handle
	
	local RightGrip = RightArm:FindFirstChild("RightGrip")
	if RightGrip then
		RightGrip:Destroy()
	end
end)

UP
This script takes the sword and welds it to the left arm instead of the right arm.

Double Sword Script


local tool = script.Parent
local SecondSword = game.ReplicatedStorage.SecondSword:Clone()

tool.Activated:Connect(function()
	local SecondSwordClone = SecondSword:Clone()
	SecondSwordClone.Parent = tool
	local char = tool.Parent
	local LeftArm = char["Left Arm"]
	local RightArm = char["Right Arm"]
	local Motor6D = Instance.new("Motor6D")
	Motor6D.Name = "LeftGrip"
	Motor6D.Parent = LeftArm
	Motor6D.Part0 = LeftArm
	Motor6D.Part1 = SecondSwordClone
end)

This script clones a part called DoubleSword thats in replicatedstorage and welds it to the left arm

These welds are Motor6Ds so they are animatable.

Hope this helps!

Is this able to be toggled? Because that is what I’m specifically looking for

Uncopylocked Place:
Toggle Hands - Roblox

Video:
Toggle.wmv (872.2 KB)

Yes, it can be toggled.

here is the new version:

Double Sword:


local tool = script.Parent
local SecondSword = game.ReplicatedStorage.SecondSword:Clone()
local double = false

local SecondSwordClone = nil

tool.Activated:Connect(function()
	local char = tool.Parent
	local LeftArm = char["Left Arm"]
	local RightArm = char["Right Arm"]
	if double then
		double = false
		if SecondSwordClone then
			SecondSwordClone:Destroy()
			SecondSwordClone = nil
		end	
		local LeftGrip = LeftArm:FindFirstChild("LeftGrip")
		if LeftGrip then
			LeftGrip:Destroy()
		end
	else
		double = true
		SecondSwordClone = SecondSword:Clone()
		SecondSwordClone.Parent = tool
		local Motor6D = Instance.new("Motor6D")
		Motor6D.Name = "LeftGrip"
		Motor6D.Parent = LeftArm
		Motor6D.Part0 = LeftArm
		Motor6D.Part1 = SecondSwordClone
	end	
end)

Left Arm Sword


local tool = script.Parent
local RightHand = true

tool.Activated:Connect(function()
	local char = tool.Parent
	local LeftArm = char["Left Arm"]
	local RightArm = char["Right Arm"]
	if RightHand then
		RightHand = false
		local Motor6D = Instance.new("Motor6D")
		Motor6D.Name = "LeftGrip"
		Motor6D.Parent = LeftArm
		Motor6D.Part0 = LeftArm
		Motor6D.Part1 = tool.Handle
	
		local RightGrip = RightArm:FindFirstChild("RightGrip")
		if RightGrip then
			RightGrip:Destroy()
		end
	else
		RightHand = true
		local Motor6D = Instance.new("Motor6D")
		Motor6D.Name = "RightGrip"
		Motor6D.Parent = RightArm
		Motor6D.Part0 = RightArm
		Motor6D.Part1 = tool.Handle

		local LeftGrip = LeftArm:FindFirstChild("LeftGrip")
		if LeftGrip then
			LeftGrip:Destroy()
		end	
	end	
end)

Thanks, it kinda works how I want to, but now I have to adjust the position of the part which I won’t need help with!

Although, I will have to correct you on declaring the “SecondSword” variable having a “:Clone()” at the end even though it is getting cloned anyways.

New issue: the part isn’t destroying when it’s supposed to be toggled off.

@WalkThroughWalls99 I apologize if I’m bothering you, but the script is causing problems for what I’m integrating it into.

  1. Sometimes, the part doesn’t destroy

or it will

  1. The part doesn’t clone and spawn in at all after running it once.

Is this a problem with how I organized my script and replicated storage or something else?