Hello! I have got some trouble with a script that rotates arms depending where the position of the mouse is. However, it seems that my motor 6D guns do not like this script, so the arms do rotate, but the Motor 6D is stuck.
Here is a gif that shows how the arms are moving but the gun is just stuck:
https://gyazo.com/6810788e243bd24e4e50feaea5601bd9
This is how I move arms and how I attempted to move the gun, which was already very close but not close enough. The “main” variable describes the ToolGrip that my gun is attached to. It is located in the Torso. I followed Stacky’s tutorial for this setup.
local rightX, rightY, rightZ = hum.Parent.Torso["Right Shoulder"].C0:ToEulerAnglesYXZ()
hum.Parent.Torso["Right Shoulder"].C0 = (hum.Parent.Torso["Right Shoulder"].C0 * CFrame.Angles(0, 0, -rightZ)) * CFrame.Angles(0, 0, math.asin((mouse.Hit.p - mouse.Origin.p).unit.y))
local leftX, leftY, leftZ = hum.Parent.Torso["Left Shoulder"].C0:ToEulerAnglesYXZ()
hum.Parent.Torso["Left Shoulder"].C0 = (hum.Parent.Torso["Left Shoulder"].C0 * CFrame.Angles(0, 0, -leftZ)) * CFrame.Angles(0, 0, math.asin((-mouse.Hit.p - -mouse.Origin.p).unit.y))
local main = hum.Parent.Torso:FindFirstChild("ToolGrip")
if main then
local rightX, rightY, rightZ = hum.Parent.Torso["Right Shoulder"].C0:ToEulerAnglesYXZ()
main.C0 = (hum.Parent.Torso["Right Shoulder"].C0 * CFrame.Angles(0, 0, 0)) * CFrame.Angles(0, 0, math.asin((mouse.Hit.p - mouse.Origin.p).unit.y)) * CFrame.Angles(0, math.rad(-90), 0)
end
This is the tutorial I used:
Can anyone please help me with how I could correctly move my gun up and down by moving the cursor?