I'm making a racing game, and I want the FOV to zoom out a tiny bit when the vehicle moves fast. How do I do this?
(I'm still a newbie)
FieldOfView is a property of the Camera.
local Players = game:GetService('Players') local Camera = workspace.CurrentCamera local Player = Players.LocalPlayer local Character = Player.Character or Player.CharacterAdded:Wait() local runningSpeed = 30 while true do wait(.1) local humanoidRootPart = Character:FindFirstChild('HumanoidRootPart') if humanoidRootPart then local hrpVelocity = humanoidRootPart.Velocity.magnitude if hrpVelocity > runningSpeed then Camera.FieldOfView = 90 -- zooms out camera else Camera.FieldOfView = 70 -- default view end -- speed check end -- a check for base part, we're using this to detect how fast a player is moving end -- while true do
You can also use TweenService as a way to smoothly move the camera in/out between walking and running.
There is a property of the camera called FieldOfView
this property is a value (which means number of any kind)
To change the FOV you must write this in a local script
local Camera = workspace.Camera while true do if --[[vehicle speed variable/directory goes here]] >= --[[the normal speed of the vehicle in numbers goes here]] then Camera.FieldOfView.Value = 90 --you can put a different value this is just what I am doing wait(0.1) end
please tell me if I made any mistakes, I hope this helped!