How do you change a CurrentCamera's Y-axis?

I’m just trying to test something. I’m making a first-person shooting game and am trying to make an anti-aimbot script.

I have a CurrentCamera and I want to make it so that if a person aims directly at a player’s head, it changes the y-axis so that their aim is completely off. Is there a way into doing this?

Here is the test code I have right now:

CC = game.Workspace.CurrentCamera

local aim = Character:FindFirstChild('Head')

if aim then
    CC.CoordinateFrame = CFrame.new(CC.CoordinateFrame.p, aim.CFrame.p)
end

Is there a way to change the y-axis of the aim.CFrame.p?

Maybe this isn’t the best way of making an anti-aimbot, but I’m just testing a few things out.

1 Like
local camera = workspace.CurrentCamera
camera.CFrame = CFrame.new(camera.CFrame.X, 0, camera.CFrame.Z)

Relatively simple just retain the X and Z components of the camera’s “CFrame” property and only change the Y component.

1 Like