Camera Fov handler based on velocity

hey there, sorry if it isnt as advanced as you expect, its pretty easy but i thought i would put it out


this will script will base the camera’s fov from the players velocity and some other things to make sure it doesnt go too bad, put this in startercharacterscripts as a local script:

local Human = game.Players.LocalPlayer.Character.Humanoid
local Camera = game.Workspace.CurrentCamera
local Tor = game.Players.LocalPlayer.Character.Torso
while true do
	Camera.FieldOfView = + 60) 
	Camera.FieldOfView = Camera.FieldOfView + 10
	Camera.FieldOfView = Camera.FieldOfView * 3

Feel free to ask any questions


This is very inefficient code, here’s why:

  1. You’re using a while true loop, which isn’t good in the slightest.
  2. You’re using wait(), which is deprecated and should be replaced by task.wait()
  3. You’re changing the same property 3 times in a row when you can just do it once.
  4. You’re using a vector3 for the first property change, which doesn’t make sense.
  5. Use workspace.INSTANCE rather than game.workspace.INSTANCE

I wouldn’t recommend anyone to use this resource.

1 Like

This is good feedback however in my opinion it is rather critical. I do agree that the code could be narrowed down to one line but, please correct me if I am wrong, it changes absolutely nothing.

As for the while true do loop, I do suggest that you change this.

For many different instances, while wait() do works much better. It will also allow you to remove the wait() on line 9.

I wasnt going to use this resurce anyway, but @vrs2210 has some good points

The script could be better, and shortened

Maybe if you take those tips and make a better script, people would use it

I think that this would be a better approach. Plus it uses lerp to make transitions smooth.


local Players = game:GetService("Players")
local Workspace = game:GetService("Workspace")
local RunService = game:GetService("RunService")

local Camera = Workspace.CurrentCamera
local Player = Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Torso = Character:WaitForChild("Torso")

local function Lerp(a: number, b: number, t: number): number
	return a + (b - a) * t

	Camera.FieldOfView = Lerp(Camera.FieldOfView, 70 + (Torso.AssemblyLinearVelocity.Magnitude * 2), deltaTime)

ah, thanks for this because im very new to scripting and just thought it would be ok,
the 3 lines is to make sure it doesnt go very close to the player as that was a problem and i could of done adding i guess,
overall i might consider re-doing this resource