Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do i make a camera zoom out button?

Asked by 5 years ago
Edited 5 years ago

Teach me how to make a camera zoom out button but i don't know how to do it. The only camera zoom out button thing i've tested is this script:

local maxZoom = game.Workspace.Camera
local CameraZoomOut = script.Parent

CameraZoomOut.MouseButton1Click:Connect(function()
      maxZoom.CFrame = CFrame.new(0,5,0)
end)
0
Any output errors? What script type is it? Is CameraZommout a TextButton? User#19524 175 — 5y
0
No output errors on this ieverhart 62 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago

I'm assuming you are attempting to do this with a localscript, if not then you should be. Firstly, try finding game.Workspace.CurrentCamera instead of just Camera. Secondly, instead of altering the Camera's actual position, you can just use FieldOfView (which I believe is defaulted to 70). Just do something like...

local Camera = game.Workspace.CurrentCamera

function ResetZoom()
    Camera.FieldOfView = 70
end

CameraZoomOut.MouseButton1Click:Connect(function()
    Camera.FieldOfView = 90
end)

--Just call the ResetZoom() function when you want to put the FieldOfView back to normal
Ad

Answer this question