My camera will not zoom in and out, even after adding a new camera | Follow up to my last post

The camera is all set to default, except the type is “Custom”, but you cannot zoom in or out with it. It uses the default camera in studio.

If you used the code I provided above, the camera will be oriented and positioned correctly.

However, if you want the client to be able to manipulate the camera with a scrollingwheel or with buttons, you will have to write this code by yourself.

Lets say you want to use the scrollingwheel to create this functionality:

local players = game:GetService("Players")
local player = players.LocalPlayer
local mouse = player:GetMouse()

mouse.WheelForward:Connect(function()
    --handle the position "zoom in"
end)

mouse.WheelBackward:Connect(function()
    --handle the position "zoom out"
end)

So, if i put your script into the game, the camera will zoom in/out normally? Or would i have to make a custom player camera?

You will have to create the zoom effect yourself.
A possible way to make zooming “smooth” is by using the tweenservice and tweening the FieldOfView Property of the camera.
local tweeninfo = TweenInfo.new(1)

local players = game:GetService("Players")
local ws	 	= game:GetService("Workspace")
local camera 	= ws.CurrentCamera
local player = players.LocalPlayer
local mouse = player:GetMouse()
local debounce = false
local tweenService = game:GetService("TweenService")
local tweenInfo = TweenInfo.new(1)
zoomInTween = tweenService:Create(camera, tweeninfo, {["FieldOfView"] = 40})
zoomOutTween = tweenService:Create(camera, tweeninfo, {["FieldOfView"] = 70})

zoomInTween.Completed:Connect(function() debounce = false end)
zoomOutTween.Completed:Connect(function() debounce = false end)

mouse.WheelForward:Connect(function() 
    if debounce == false then
        debounce = true
        --handle the position "zoom in"
        zoomInTween:Play()
    end
end)

mouse.WheelBackward:Connect(function()
    if debounce == false then
        debounce = true
        --handle the position "zoom out"
        zoomOutTween:Play()
    end
end)

2 Likes

Do I paste the script into the camera into workspace? Also, would it work for mobile/Ipad/Tablet users?

Cameras do NOT replicate, meaning the client would never be able to see the Camera created on the server, they will only see their own camera, which is the same one used to follow the character. You would have to set the CameraType to Scriptable through a LocalScript and use UserInputService to listen for scrolling, right click start/end, and mouse movement, then use the data to write your own implementation of the Camera script.

I know, I am probably wasting your guys time, with my stupidity. But I don’t really get it.

So, I use the script, and also script the other camera features?

The camera you create in Roblox Studio will not be present for clients; you MUST use a LocalScript on the client to create the Camera, set it up, and write your own method of controlling the camera.

I know I am really stupid, I have never done camera scripting before. If I implement the script, everything in the camera will work?

I am probably just stupid. I have never messed/scripted a camera.

It definitely isn’t an easy task, and would require an intricate knowledge of how CFrames (transformation matrices) work and how to manipulate them in the way you would like.

you can have an offset and zoom delta too after applying the above knowledge,
after that you can apply a rotation.

local cframePos = CFrame.new(0,0,0)
local offset = Vector3.new(0, 0, 1)
local zoom = 5

local yaw = 0
local pitch = 0
local roll = 0

camera.CFrame = (cframePos  + offset * zoom) * CFrame.Angles(math.rad(yaw), math.rad(pitch), math.rad(roll))

if your wanting to make your own orbital camera, then that will take a different route.

EDIT: if your talking about the server camera (the camera you are using before you press play) then I don’t know.

So, I have to make a entirely new camera by my self? Or do I implement the script in the camera, and then I would be able to zoom in/out?

So, your talking about the one In explorer, right?

If yes, it’s the one I’m talking about. You cannot zoom in or out.

alright, if you set the server cameras property to Custom then some functions aren’t available, you can just change it back to Fixed.

It is stuck on fixed as well, and on all the other options.

I might be back in around 30 minutes - 2 hours. So I will try to continue this when I’m back. Sorry to bother you.

Don’t know if you are there or not. But I am back.

This was great, everything worked as it should be and very smooth , thank you