I made a script that makes the arms and head follow the camera on the Y axis for R15 and R6 characters for my FPS game. The head works fine but the arms are in places that they shouldn’t be in, like in the head and torsos position. Please help as I have tried lots of ways to fix the arms!
R6:
robloxapp-20211121-1301289.wmv (716.4 KB)
R15:
robloxapp-20211121-1302556.wmv (1.1 MB)
This is the script:
local tweenService = game:GetService("TweenService")
local Camera = workspace.CurrentCamera
local Player = game.Players.LocalPlayer
local Character = Player.Character
local Root = Character:WaitForChild("HumanoidRootPart")
local Neck = Character:FindFirstChild("Neck", true)
local YOffset = Neck.C0.Y
local CFNew, CFAng = CFrame.new, CFrame.Angles
local asin = math.asin
game:GetService("RunService").RenderStepped:Connect(function()
local CameraDirection = Root.CFrame:toObjectSpace(Camera.CFrame).lookVector
if Neck then
if Character.Humanoid.RigType == Enum.HumanoidRigType.R15 then
Neck.C0 = CFNew(0, YOffset, 0) * CFAng(asin(CameraDirection.y), 0, 0)
local YOffset2 = Character.RightUpperArm.RightShoulder.C0.Y
local YOffset3 = Character.LeftUpperArm.LeftShoulder.C0.Y
Character.RightUpperArm.RightShoulder.C0 = CFNew(0, YOffset2, 0) * CFAng(asin(CameraDirection.y), 0, 0)
Character.LeftUpperArm.LeftShoulder.C0 = CFNew(0, YOffset3, 0) * CFAng(asin(CameraDirection.y), 0, 0)
elseif Character.Humanoid.RigType == Enum.HumanoidRigType.R6 then
Neck.C0 = CFNew(0, YOffset, 0) * CFAng(3 * math.pi/2, 0, math.pi) * CFAng(-asin(CameraDirection.y), 0, 0)
local YOffset2 = Character.Torso['Right Shoulder'].C0.Y
local YOffset3 = Character.Torso['Left Shoulder'].C0.Y
Character.Torso['Right Shoulder'].C0 = CFNew(0, YOffset2, 0) * CFAng(3 * math.pi/2, 0, math.pi) * CFAng(-asin(CameraDirection.y), 0, 0)
Character.Torso['Left Shoulder'].C0 = CFNew(0, YOffset3, 0) * CFAng(3 * math.pi/2, 0, math.pi) * CFAng(-asin(CameraDirection.y), 0, 0)
end
end
end)
game.ReplicatedStorage.Look.OnClientEvent:Connect(function(otherPlayer, neckCFrame)
local Neck = otherPlayer.Character:FindFirstChild("Neck", true)
if Neck then
tweenService:Create(Neck, TweenInfo.new(.5, Enum.EasingStyle.Quad, Enum.EasingDirection.Out, 0, false, 0), {C0 = neckCFrame}):Play()
end
end)

