You can write your topic however you want, but you need to answer these questions:
What do you want to achieve? Keep it simple and clear!
I want to make the fov of the player change depending on the amount of speed the car has.
(to achieve a sense of speed, basically)
What is the issue? Include screenshots / videos if possible!
i tried making a script so it changes the fov based on what i talked above (car speed), but it didnt work.
here are the scripts:
local cam = game.Workspace.CurrentCamera
while true do
local MaxSpeed = script.Parent.MaxSpeed
local CurrentSpeed = script.Parent.Velocity.Magnitude
wait(.2)
cam.FieldOfView = ((CurrentSpeed / MaxSpeed) * 70) + 70
end
^
this one is inside the car.
local cam = game.Workspace.CurrentCamera
cam.CameraType = Enum.CameraType.Scriptable
^
and this one is to change the camera type to scriptable, its located in the workspace
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I searched around many posts in here, but none of them were helpful since it wasnt what i was looking for.
the math is also made so you cant go below 70 of FOV, but cant go beyond 140, but other than that i cant get my head around any idea as of why this isnt working.
i also tried doing a simple test to see if the fov of the camera changed with scripts:
local cam = workspace.CurrentCamera
local car = path.to.car
local RunService = game:GetService("RunService")
local function render()
if cam.CameraType ~= Enum.CameraType.Scriptable then
cam.CameraType = Enum.CameraType.Scriptable
end
local maxSpeed = car.MaxSpeed.Value -- I suppose this is a NumberValue
local currentSpeed = car.Velocity.Magnitude
cam.FieldOfView = ((currentSpeed / maxSpeed) * 70) + 70
end
RunService.RenderStepped:Connect(render)
Make sure this is a local script, and make sure it’s in one of these locations: StarterPlayerScripts, StarterGui, StarterPack, e.t.c