Camera script does not let me zoom out, no errors in F9 and I can’t figure it out. Searched on the developer forum, can’t find an answer there either.
local players = game:GetService("Players")
local userInputService = game:GetService("UserInputService")
local userGameSettings = UserSettings():GetService("UserGameSettings")
local player = players.LocalPlayer
local mouse = player:GetMouse()
local character = player.Character or player.CharacterAdded:Wait()
local humanoidRootPart = character:WaitForChild("HumanoidRootPart")
local camera = workspace.CurrentCamera
local cameraHeightOffset = 1.5
local cameraFOV = 20
local cameraDepth = 70
camera.FieldOfView = cameraFOV
local currentAngle = 0
local function updateCamera(deltaTime)
local mouseDeltaX = userInputService:GetMouseDelta().X
currentAngle += -mouseDeltaX * deltaTime * userGameSettings.MouseSensitivity * 1.2 -- the 1.2 multiplier is required to make the sensitivity similar to regular roblox camera
local rootPosition = humanoidRootPart.Position + Vector3.new(0, cameraHeightOffset, 0)
local cameraCFrame = CFrame.new(rootPosition) * CFrame.Angles(0, currentAngle, 0) * CFrame.new(Vector3.new(cameraDepth, cameraDepth, cameraDepth))
camera.CFrame = CFrame.lookAt(cameraCFrame.Position, rootPosition)
end
game:GetService("RunService"):BindToRenderStep("TopDownCamera", Enum.RenderPriority.Camera.Value + 1, updateCamera)
local cameraDepthCheckValue = cameraDepth
mouse.WheelForward:Connect(function()
if camera.CFrame.Y > 20 and cameraDepthCheckValue > 20 then
cameraDepthCheckValue -= 10
task.spawn(function()
for i = 1, 10 do
cameraDepth -= 1
task.wait()
end
end)
end
end)
mouse.WheelBackward:Connect(function()
if camera.CFrame.Y < 110 and cameraDepthCheckValue < 110 then
cameraDepthCheckValue += 10
task.spawn(function()
for i = 1, 10 do
cameraDepth += 1
task.wait()
end
end)
end
end)
Any help is appreciated!