Issue with welding script for unsheathing a weapon

  1. What do you want to achieve? Keep it simple and clear!

I am trying to create a script that, once the E key is pressed, welds a weapon to the character’s hand.

  1. What is the issue? Include screenshots / videos if possible!

The weld I am attempting to create does not weld to the character’s hand and rather spawns far away; eventually destroyed for an unknown reason. It does, however, work if the E key is pressed in quick succession when the game is launched.

  1. What solutions have you tried so far? Did you look for solutions on the Developer Hub?

I looked on the developer hub for possible issues with the weld, but nothing seemed to align with my specific issue

server-side script

game:GetService("Players").PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(char)
		remotes.WeldRe.OnServerEvent:Connect(function(player, weapon, equipping)
			if equipping == true then
				char:FindFirstChild("WeaponModel"):Destroy()
				local Tweapon = weapon:Clone()
				local w = Instance.new('Weld')
				w.Part0 = weapon.Handle
				w.Part1 = char:WaitForChild("RightHand")
				w.C1 = CFrame.Angles(math.rad(90),math.rad(180),math.rad(180))
				Tweapon.Parent = char
				w.Parent = weapon
			
			else
				char[weapon.Name]:Destroy()
			end
		end)

client-side

if key.KeyCode == Enum.KeyCode.E and cd == false then
		print(Equipped)
		if Equipped == false then
			print("Equipped")
			WeaponType = EquppedWeapon:GetAttribute("WeaponType")
			remotes.WeldRe:FireServer(EquppedWeapon, true) --true to equip, false to unequip
			Hitbox = RaycastModule.new(EquppedWeapon.WeaponModel)
			Hitbox.RaycastParams = RaycastParams
			Anim.AnimationId =  weaponData[WeaponType]["SHEATHE"]
			local load = Humanoid:LoadAnimation(Anim)
			load:Play()
			Hitbox.OnHit:Connect(function(hit, humanoid)
				if hit.Parent:FindFirstChild("Humanoid") then
					remotes.DamageRe:FireServer(hit, humanoid)
				end
			end)
			
		else
			print("unequipped")
			WeaponType = nil
			remotes.WeldRe:FireServer(EquppedWeapon, false)
		end
		cd = true
		wait(2)
		cd = false
		Equipped = not Equipped
	end

Any insight as to where I am going wrong would be super helpful!