How do I weld a part's position but not its rotation?
Howdy. I am welding a gun to my character's right hand. It cannot be a tool for many reasons, first and foremost that it needs to rotate to face my mouse (think Metroid Prime). This is the code inside my gun:
02 | playerTable = game.Players:GetChildren() |
03 | player = playerTable [ 1 ] |
05 | mouse = player:GetMouse() |
06 | weld = Instance.new( "Weld" ) |
07 | weld.Parent = script.Parent |
08 | weld.Part 0 = weld.Parent |
09 | weld.Part 1 = player.Character [ "Right Arm" ] |
10 | weld.C 0 = CFrame.new( 0 , 1 , 0 ) |
13 | script.Parent.CFrame = CFrame.new(script.Parent.CFrame.p, mouse.Hit.p) |
As you would expect, this code welds the gun to the player's right arm one stud up. The problem comes with the CFrame's second vector. It works perfectly, sort of: the gun does rotate towards the mouse. The problem? It is welded to my character, so my character faces my mouse as well. Any help is appreciated. Thanks in advance.