I made a script so that if you were to move your mouse up and down, the head and arms would follow it. The head is completely fine, but as you can see from the GIF, the arms are rotated the wrong way. How would I make them have the correct rotation?
GIF: https://gyazo.com/64c2667cf957639038c2b761be03e620
Script for the right arm:
local Player = game.Players.LocalPlayer
local RunService = game:service("RunService")
repeat wait() until Player.Character
local Char = Player.Character
local Torso = Char:findFirstChild("Torso")
local RArm = Torso["Right Shoulder"]
local Camera = workspace.CurrentCamera
local Mouse = Player:GetMouse()
while RunService.RenderStepped:wait() do
local LookVector = Mouse.UnitRay.Direction
local Adjacent = math.sqrt((LookVector.X^2)+(LookVector.Z^2))
local Opposite = LookVector.Y
local Angle = math.atan2(Opposite, Adjacent)
RArm.C0 = CFrame.new(1.5,0.05,0)*CFrame.Angles(Angle+(math.pi/2),math.pi,0)
end
Script for the left arm:
local Player = game.Players.LocalPlayer
local RunService = game:service("RunService")
repeat wait() until Player.Character
local Char = Player.Character
local Torso = Char:findFirstChild("Torso")
local LArm = Torso["Left Shoulder"]
local Camera = workspace.CurrentCamera
local Mouse = Player:GetMouse()
while RunService.RenderStepped:wait() do
local LookVector = Mouse.UnitRay.Direction
local Adjacent = math.sqrt((LookVector.X^2)+(LookVector.Z^2))
local Opposite = LookVector.Y
local Angle = math.atan2(Opposite, Adjacent)
LArm.C0 = CFrame.new(-1.5,0.05,0)*CFrame.Angles(Angle+(math.pi/2),math.pi,0)
end
