Im sure some sort of simulation game out there is in need of an FOV changer for taking pretty photos to hang on your wall. Most games I’ve seen use a free model FOV slider from the toolbox which is annoying to control because you can only change it in third person since your mouse is locked in first person.
I have a solution!
This script decreases your FOV when you hold “Z” and increases it when you hold “X”
There is also a text label that displays your FOV however this is completely optional.
Script:
local UserInputService = game:GetService("UserInputService")
local localPlayer = game.Players.LocalPlayer
local camera = workspace.CurrentCamera
local FOVLabel = script.Parent
local maxFov = 70
local minFov = 20
local function updateFOVLabel()
if UserInputService:IsKeyDown(Enum.KeyCode.Z) or UserInputService:IsKeyDown(Enum.KeyCode.X) then
FOVLabel.Visible = true
FOVLabel.Text = "FOV: ".. math.floor(camera.FieldOfView)
else
FOVLabel.Visible = false
end
end
UserInputService.InputBegan:Connect(function(input)
if input.KeyCode == Enum.KeyCode.Z then
while task.wait() and input.UserInputState == Enum.UserInputState.Begin do
camera.FieldOfView = camera.FieldOfView - 0.75
if camera.FieldOfView <= minFov then
camera.FieldOfView = minFov
break
end
updateFOVLabel()
end
elseif input.KeyCode == Enum.KeyCode.X then
while task.wait() and input.UserInputState == Enum.UserInputState.Begin do
camera.FieldOfView = camera.FieldOfView + 0.75
if camera.FieldOfView >= maxFov then
camera.FieldOfView = maxFov
break
end
updateFOVLabel()
end
end
end)
UserInputService.InputEnded:Connect(function(input)
if input.KeyCode == Enum.KeyCode.Z or input.KeyCode == Enum.KeyCode.X then
updateFOVLabel()
end
end)
No text label version:
local player = game.Players.LocalPlayer
local camera = workspace.CurrentCamera
local maxFov = 70
local minFov = 20
game:GetService("UserInputService").InputBegan:Connect(function(input)
if input.KeyCode == Enum.KeyCode.Z then
while task.wait() and input.UserInputState == Enum.UserInputState.Begin do
camera.FieldOfView = camera.FieldOfView - 0.75
if camera.FieldOfView <= minFov then
camera.FieldOfView = minFov
break
end
end
elseif input.KeyCode == Enum.KeyCode.X then
while task.wait() and input.UserInputState == Enum.UserInputState.Begin do
camera.FieldOfView = camera.FieldOfView + 0.75
if camera.FieldOfView >= maxFov then
camera.FieldOfView = maxFov
break
end
end
end
end)
Example of how you should set it out: