Hello! I’ve made a script that allows player having their head, arms and tool (and the tool is connected to torso with a Motor6D) looks toward cursor but i discover a issue that i can’t solve, i keep finding the solution but couldn’t.
So here’s the issue
When player looks up their tools rotate in Y axis (red circle) is located in the center of player’s torso which will resulting the tool shove into their mouth or the tool, what i want is making it possible so when player looks up, the tool will move and rotate with the arm resulting exactly same distance between those parts (similar to the green circle)
Local Script :
local toolX, toolY, toolZ = char.Torso.Tool.C1:ToEulerAnglesYXZ()
toolgrip.C0 = CFrame.Angles(math.asin((Mouse.Hit.Position - Mouse.Origin.Position).Unit.Y),0,0)
-- These script below works fine --
local headX,headY,headZ = char.Torso.Neck.C0:ToEulerAnglesYXZ()
Neck.C1 = CFrame.new(0,-0.5,0) * CFrame.Angles(math.rad(90),math.rad(-180),0) * CFrame.Angles(math.asin((Mouse.Hit.Position - Mouse.Origin.Position).Unit.y),0,0)
local rightX, rightY, rightZ = char.Torso["Right Shoulder"].C0:ToEulerAnglesYXZ()
Rarm.C0 = (char.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 = char.Torso["Left Shoulder"].C0:ToEulerAnglesYXZ()
Larm.C0 = (char.Torso["Left Shoulder"].C0 * CFrame.Angles(0, 0, -leftZ)) * CFrame.Angles(0, 0, math.asin((-Mouse.Hit.p - -Mouse.Origin.p).Unit.y))
equippedre:FireServer(toolgrip.C0,Neck.C1,Rarm.C0,Larm.C0)
Server Script :
equippedre.OnServerEvent:Connect(function(player,toolgrip,neck,rshoulder,lshoulder)
workspace:WaitForChild(player.Name):WaitForChild("Torso"):WaitForChild("Tool").C0 = toolgrip
workspace:WaitForChild(player.Name):WaitForChild("Torso"):WaitForChild("Neck").C1 = neck
workspace:WaitForChild(player.Name):WaitForChild("Torso"):WaitForChild("Right Shoulder").C0 = rshoulder
workspace:WaitForChild(player.Name):WaitForChild("Torso"):WaitForChild("Left Shoulder").C0 = lshoulder
end)