hey there, sorry if it isnt as advanced as you expect, its pretty easy but i thought i would put it out
Anyway,
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 = Vector3.new(Tor.Velocity.magnitude + 60)
Camera.FieldOfView = Camera.FieldOfView + 10
Camera.FieldOfView = Camera.FieldOfView * 3
wait()
end
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 think that this would be a better approach. Plus it uses lerp to make transitions smooth.
--!strict
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
end
RunService.Heartbeat:Connect(function(deltaTime)
Camera.FieldOfView = Lerp(Camera.FieldOfView, 70 + (Torso.AssemblyLinearVelocity.Magnitude * 2), deltaTime)
end)
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