Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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?

3 comments

0

Use UserInputService to catch the key press/release and adjust the camera's FOV.

0

I have no idea how to use the "UserinputService"

0

Please accept my answer. It’s rude to steal my work

1 answer

✓ Accepted answer
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)

5 comments

0

It doesn't zoom back to the normal FOV

0

oh wait nvm i can fix it\

1

Don't forget to accept Feahren's answer!

0

Of course it won’t, it wasn’t programmed to.

0

and i fixed that

This discussion is preserved as it was. New answers, comments, and votes are closed.