Zooming out in scriptable

The Problem
Hi there, I’m trying to make a camera system that makes it so you can rotate your camera without having to right-click. While I figured out how to make that, one thing doesn’t seem to work. The scrolling system. I want the player to be able to scroll just like in the normal camera mode.

What have I tried?
I have tried this piece of code to get the zoom distance.

(camera.CFrame.Position - camera.Focus.Position).Magnitude

My assumptions
Most likely, it doesn’t work, because the camera-type is scriptable and in scriptable you can’t zoom in or out.

The question
Is there any solution for this? I first thought about just recreating the whole scrolling system, but that seems pretty inefficient, so I was wondering if there’s any other way to reach this.

Thanks for reading!

I’m pretty sure setting camera type to Scriptable gets rid of all the camera controlling core scripts, including zooming. You probably need to recreate the scrolling system.

if im right u just set the Z of the Camera Cframe

u can just do

local runService = game:GetService("RunService")
local Player = game:GetService("Players").LocalPlayer
local Camera = game:GetService("Workspace").CurrentCamera

local CurrentZoomZ = 5

local Mouse = Player:GetMouse()

local cameraPos = Vector3.new(0,0,CurrentZoomZ)

Mouse.WheelBackward:Connect(function()
	if CurrentZoomZ == game.StarterPlayer.CameraMaxZoomDistance then return end
	CurrentZoomZ = CurrentZoomZ + 1.5
	cameraPos = Vector3.new(2.5,0,CurrentZoomZ)
	if CurrentZoomZ > game.StarterPlayer.CameraMaxZoomDistance then
		cameraPos = Vector3.new(2.5,0,game.StarterPlayer.CameraMaxZoomDistance)
	end
end)

Mouse.WheelForward:Connect(function()
	if CurrentZoomZ == game.StarterPlayer.CameraMinZoomDistance then return end
	CurrentZoomZ = CurrentZoomZ - 1.5
	cameraPos = Vector3.new(2.5,0,CurrentZoomZ)
	if CurrentZoomZ < game.StarterPlayer.CameraMinZoomDistance then
		cameraPos = Vector3.new(2.5,0,game.StarterPlayer.CameraMinZoomDistance)
	end
end)

runService.RenderStepped:Connect(function()
        Camera.CFrame = CFrame.new(CameraPos)
end) 

IF U WANT SHIFT LOCK OR CUSTOM/SCRIPTABLE CAMERA DM ME
KalaYo#9591 Discord

1 Like

Oh sorry, should have closed this, I already have got a solution.