Parse camera lookVector into Y Orientation

So I’m in the middle of writing a wall walk script, I’ve come to a cross road as I don’t know how I’m suppose to render the lookVector of the camera as a single vector on the y axis of orientation. The code I already wrote would work normally but were on the side of a wall…

  • The example below further explains this idea
local p1 ="Part", game.Workspace)
p1.Anchored = true
p1.Transparency = 1
p1.CanCollide = false
local p2 ="Part", game.Workspace)
p2.Anchored = true
p2.Transparency = .4
p2.CanCollide = false
p2.BrickColor ="Really red")
p2.Material = Enum.Material.Neon
local humPos = char.HumanoidRootPart.CFrame* CFrame.Angles(math.rad(-90), math.rad(0), math.rad(0))
p1.CFrame =, camera.CFrame.p)
p2.CFrame = CFrame.Angles(0, -math.pi / 2 - math.atan2(camera.CFrame.p.Z - p1.CFrame.Z, camera.CFrame.p.X - p1.CFrame.X), 0)
orientationY = (p2.Orientation.y-char.HumanoidRootPart.Orientation.y)-180
print("NEW Y:"..(p2.Orientation.y-char.HumanoidRootPart.Orientation.y))

I’m a little confused by what you mean here? Can you elaborate on what you’re trying to do?

1 Like

Never mind I was able to fix it on my own by making the follow changes
CFrame.Angles(0, -math.pi / 2 - math.atan2(camera.CFrame.p.Y - p1.CFrame.Y, camera.CFrame.p.Z - p1.CFrame.Z), 0)
I also made the value be subtracted depending on which direction I was heading