How do I compensate for the roll on a camera head lock codeline? [SELF-SOLVED]

character.Humanoid.CameraOffset = Vector3.new(0, -1 + (character.Torso.CFrame.UpVector.Y) + -(character.HumanoidRootPart.Position.Y - character.Torso.Position.Y), -1 + (character.Torso.CFrame.LookVector.Y * 2))

I tuned a previously used line of code to allow it to be used for R6, and used it to make it so the camera was locked to the player’s eyes. It works completely fine, except for animations that cause you to roll side-to-side. I need to make it so there is compensation for that, as LookVector.Y changes while rolling, causing the offset to spazz out.

It’s not game-breaking, as I can simply just play the game in third person (intended) but it would be nice if the script worked for special animations for characters as well.

I’ll try to use an Attachment and use its position in order to set the correct camera offset. If it doesn’t work, I need help pretty bad

Figured out that UpVector was way more stable than LookVector. Sucks that nobody replied though. If anyone ends up using a system like this or just wants a first-person script please use this updated code (R15 is probably compatible as well because the code came from an R15 game, just replace all instances of Torso with UpperTorso.

character.Humanoid.CameraOffset = Vector3.new(0, -1 + (character.Torso.CFrame.UpVector.Y) + -(character.HumanoidRootPart.Position.Y - character.Torso.Position.Y), -2.5 + (character.Torso.CFrame.UpVector.Y))

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.