I am working on a fighting game and am adding the ability to “aim” your sword slashes based on where you look. The problem is that the arms will follow the camera just fine but the tools, which I used a Motor6d to attach to the torso, will not follow the arm on their own. I don’t know how to proceed.
game:GetService("RunService").RenderStepped:Connect(function()
local CameraDirection = Root.CFrame:toObjectSpace(camera.CFrame).lookVector
if Neck and humanoid.Health > 0 then
if player.Character.Humanoid.RigType == Enum.HumanoidRigType.R6 then
Neck.C0 = CFNew(0, YOffset, 0) * CFAng(3 * math.pi/2, 0, math.pi) * CFAng(0, 0, -asin(CameraDirection.x)) * CFAng(-asin(CameraDirection.y), 0, 0)
leftArm.C0 = leftArmOrigin
rightArm.C0 = rightArmOrigin
if player.Character:FindFirstChildOfClass("Tool") then
rightArm.C0 = CFNew(1, 0.5, 0) * CFAng(3 * math.pi/2, 0, math.pi) * CFAng(-asin(CameraDirection.y), 0, 0) * CFAng(4.7,4.7,9.5)
leftArm.C0 = CFNew(-1, 0.5, 0) * CFAng(3 * math.pi/2, 0, math.pi) * CFAng(-asin(CameraDirection.y), 0, 0)* CFAng(7.5,1.5,6.5)
end
end
end
end)