Tool Weld interfering with CFrame

So I’m trying to make a first person view model that’s tracked to the camera, and so far I have just the arms and the hands working as expected.

The way I do it is copy everything in the character into a separate model based off of these rules:

  • It’s a BasePart that is a part of an arm
    OR
  • It’s not a BasePart, Script, Attachment, or Joint

I run BreakJoint on every BasePart that’s added to this clone. The clone is then put under a section of the character model that is marked as visible in the camera script which I’ve modified. I CFrame this clone every frame so that the head of the cloned model lines up with your camera in first person and your character’s head in third person.

This is where the bug is
I have an event that listens for RightHand.ChildAdded which looks for the object “RightGrip”. If it finds it, then it swaps Part0 of Character.RightHand.RightGrip from Character.RightHand to ViewModel.RightHand

The problem is that when I change Part0 to the right hand it

  1. Moves the right hand, even though I’m CFraming it every single frame and there are no other joints attached to it, and
  2. The weapon acts as though it’s is being held by a completely different part than Handle, even though I don’t change Part1. The minigun for example spins around by the body of the gun instead of the barrel.
    - YouTube
  3. Is actually in the correct position on the handle

This is what it looks like


I have tried anchoring the right hand and replacing the weld with a Motor6D. This works fairly well except:

  1. It can’t be done on the client purely locally, as the creation does not replicate to the server, and on the server it will appear like you are not holding the weapon. In addition, the weapon gets destroyed shortly afterwards.
  2. This has another issue where if you switch weapons really fast it can cause you to teleport to where your view model is, which under normal circumstances teleports you back relative to your camera a small distance. If you do this really fast it will let you fly no-clip backwards. I tried fruitlessly for hours today to fix the bug, and it appears to be some kind of engine bug which caused your right hand to be welded to the handle, and then the handle was welded to your view model’s right hand, despite the fact that I traversed Handle:GetJoints(), deleted all the joints that were connected to Character.RightHand, and waited. I think the error comes from a race condition where very occasionally the RightGrip weld is replicated after the Motor6D is created, causing a joint to momentarily exist, connecting the right hand of the character to the handle, which is already connected to the view model. I’m pretty sure this method is a no go.
  3. There is a non-insignificant period of time where the weapon is not in your hand that comes down to lag.

Welds do not work properly when one of the parts is anchored (i.e. ViewModel.RightHand)

1 Like