local runService = game:GetService("RunService")
local players = game:GetService("Players")
local userInputService = game:GetService("UserInputService")
local replicateStorage = game:GetService("ReplicatedStorage")
local lookRemote = replicateStorage.Remotes.Character.LookAt
local player = players.LocalPlayer
local mouse = player:GetMouse()
local character = player.Character or player.CharacterAdded:Wait()
local root = character:WaitForChild("HumanoidRootPart")
local humanoid = character:WaitForChild("Humanoid")
local torso = character:WaitForChild("Torso")
local rightShoulder = torso:WaitForChild("Right Shoulder")
local leftShoulder = torso:WaitForChild("Left Shoulder")
local neck = torso:WaitForChild("Neck")
local turnSpeed = 0.05
local aimingState = false
local RC0_Origin = CFrame.new(1, 0.5, 0, 0, 0, 1, 0, 1, 0, -1, 0, 0)
local LC0_Origin = CFrame.new(-1, 0.5, 0, 0, 0, -1, 0, 1, 0, 1, 0, 0)
local Neck_Origin = CFrame.new(0, 1, 0, -1, 0, 0, 0, 0, 1, 0, 1, -0)
local gunAttach
local Gun_C0_Origin
local Gun_C1_Origin
local HandOffset = CFrame.new(0, -0.5, -1) * CFrame.Angles(0, math.rad(-90), 0)
character:GetAttributeChangedSignal("Aiming"):Connect(function()
aimingState = character:GetAttribute("Aiming")
humanoid.AutoRotate = not aimingState
if aimingState then
gunAttach = torso:FindFirstChild("GunAttach")
if gunAttach then
Gun_C0_Origin = gunAttach.C0
Gun_C1_Origin = gunAttach.C1
end
end
if not aimingState then
rightShoulder.C0 = RC0_Origin
leftShoulder.C0 = LC0_Origin
neck.C0 = Neck_Origin
if gunAttach and Gun_C0_Origin and Gun_C1_Origin then
gunAttach.C0 = Gun_C0_Origin
gunAttach.C1 = Gun_C1_Origin
end
end
end)
runService.RenderStepped:Connect(function()
if not aimingState then return end
local hitPos = mouse.Hit.Position
if not hitPos then return end
local angle = math.asin(mouse.Origin.LookVector.Y)
local rightArmRotation = RC0_Origin * CFrame.Angles(0, 0, angle)
local leftArmRotation = LC0_Origin * CFrame.Angles(0, 0, -angle)
local neckRotation = Neck_Origin * CFrame.Angles(-angle, 0, 0)
rightShoulder.C0 = rightShoulder.C0:Lerp(rightArmRotation, turnSpeed)
leftShoulder.C0 = leftShoulder.C0:Lerp(leftArmRotation, turnSpeed)
neck.C0 = neck.C0:Lerp(neckRotation, turnSpeed)
if gunAttach then
gunAttach.C1 = CFrame.new()
gunAttach.C0 = rightShoulder.C0 * HandOffset
end
local flatTarget = Vector3.new(hitPos.X, root.Position.Y, hitPos.Z)
local targetCF = CFrame.lookAt(root.Position, flatTarget)
root.CFrame = root.CFrame:Lerp(targetCF, turnSpeed)
--lookRemote:FireServer(angle)
end)
Currently this is my code for the rotation, but somehow when i point up or down my arms would eventually got curved.
Ive read several posts, but could not found any solutions.



