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

How Do You Make a Camera Zoom On a Key Press?

Asked by 4 years ago

So I'm making a game and I'm trying to make a zoom happen when you press Q on your keyboard any idea how I can do this?

0
Use `UserInputService` to catch the key press/release and adjust the camera's FOV. f59ph_iv 0 — 4y
0
I have no idea how to use the "UserinputService" Cookie_clicker2 16 — 4y
0
Please accept my answer. It’s rude to steal my work Ziffixture 6913 — 4y

1 answer

Log in to vote
1
Answered by
Ziffixture 6913 Moderation Voter Community Moderator
4 years ago
local UserInputService = game:GetService("UserInputService")

local Player = game.Players.LocalPlayer

UserInputService.InputBegan:Connect(function(InputKey, GameProcessed)
    if (GameProcessed) then return end
    if (InputKey.KeyCode == Enum.KeyCode.Q) then
        local Camera = workspace.CurrentCamera
        Camera.FieldOfView = (Camera.FieldOfView - --[[ZoomDistance]])
    end
end)
0
It doesn't zoom back to the normal FOV Cookie_clicker2 16 — 4y
0
oh wait nvm i can fix it\ Cookie_clicker2 16 — 4y
1
Don't forget to accept Feahren's answer! JPT79 92 — 4y
0
Of course it won’t, it wasn’t programmed to. Ziffixture 6913 — 4y
0
and i fixed that Cookie_clicker2 16 — 4y
Ad

Answer this question