# How to fix my camera angle in ROBLOX?

I am trying to make my own camera in ROBLOX. Here's my problem, I am using an inverse function to make the camera look nice and smooth but it only works on the x axis in the positive side.

Here's an example of the zoom in and the zoom out of my camera:

For now we can think it's working but if I put my player on a different axis like this:

We can see that the inverse animation is only in the x and y axis and now heres the little part of my code:

for x = 1, 15 do
y = 10
camera.CFrame = CFrame.new(Vector3.new(y/x, x+5, camera.CFrame.p.z), character.Head.Position)
wait(0)
end


What can I do to make it work in the z axis too?