I’ve been trying to make a tool that, when you hold it, is supposed to make the Right arm aim where the mouse is pointing in the 3D world. It works, but when I try to copy that over to the Left Arm, I don’t know why the offset looks like this. The Left arm is supposed to be on the Grip, which the animation does automatically. When I look straight in the first person it looks fine, However when I look down or leave the first person. it’s obvious how weird it becomes
FOWARD
DOWN
3RD Person
Code:
local RunService = game:GetService("RunService")
local Players = game:GetService("Players")
local player = Players.LocalPlayer
local mouse = player:GetMouse()
local character = player.Character or player.CharacterAdded:Wait()
local torso = character:WaitForChild("Torso")
local rightShoulder = torso:WaitForChild("Right Shoulder")
local leftShoulder = torso:WaitForChild("Left Shoulder")
local originalRightC0 = rightShoulder.C0
local originalLeftC0 = leftShoulder.C0
local equipped = false
local tool = script.Parent
tool.Equipped:Connect(function()
equipped = true
end)
tool.Unequipped:Connect(function()
equipped = false
rightShoulder.C0 = originalRightC0
leftShoulder.C0 = originalLeftC0
end)
RunService.RenderStepped:Connect(function()
if not equipped then return end
local rightWorldC0 = torso.CFrame * originalRightC0
local aimDirection = (mouse.Hit.Position - rightWorldC0.Position).Unit
local aimedRightWorld = CFrame.lookAt(rightWorldC0.Position, rightWorldC0.Position + aimDirection) * CFrame.Angles(0, math.rad(90), 0)
local aimedRightRelative = torso.CFrame:ToObjectSpace(aimedRightWorld)
rightShoulder.C0 = aimedRightRelative
local leftWorldOrigin = torso.CFrame * originalLeftC0
local mirroredLeftWorld = CFrame.new(leftWorldOrigin.Position) * aimedRightWorld.Rotation * CFrame.Angles(0, math.rad(180), 0)
local finalLeftRelative = torso.CFrame:ToObjectSpace(mirroredLeftWorld)
leftShoulder.C0 = finalLeftRelative
end)