Hello, I’m trying to make all these rigs turn their head to face the camera so I can make a thumbnail for a game, but when their torso is rotated, they don’t look in the right place.
Here’s my code:
for i, char in pairs(game.Workspace.Characters:GetChildren()) do
local yDifference = (char.Head.CFrame.Y - char.Torso.Neck.C0.Y)/4.5
local direction = (Vector3.new(game.Workspace.Camera.CFrame.p.X, char.Head.Position.Y, game.Workspace.Camera.CFrame.p.Z) - char.Head.Position).Unit
char.Torso.Neck.C0 = CFrame.new(0, yDifference, 0) * CFrame.Angles(3 * math.pi/2, 0, math.pi) * CFrame.Angles(0, 0, -math.asin(direction.X)) * CFrame.Angles(-math.asin(direction.Y), 0, 0)
end