To do it automatically you will have to use looping or tweening.
Here is an example of a really basic one which can cycle up and down to a goal:
number = 50
waitTime = 0.1
amount = 1
function(goal)
local step = 0
--// The entire purpose of this first bit is just to calculate the step in some feasible way.
-- You could easily achieve the same thing with other maths.
if goal == number then -- we've done this just because we don't know if the value is there.
print("No movement needed.")
elseif goal > number then
step = amount
else
step = -(amount)
end
if step then
repeat
number = number + step
wait(waitTime)
-- You could then set a value to this number.
until number == goal
end
end
This is a really basic example and you could shorten / edit a lot of things - but its so you get the idea.
repeat and while loops are your main ones, however you could also use for loops for transition.
If you want to do it on a property with no self written function and for it always to take x amount of time you may want to look into the TweenService. This can be great for changing things like your FOV and its applicable for loads of situations.
Pretty simple… Seems like you are a beginner you just need a loop.
Example localscript:
local Camera = workspace.CurrentCamera -- UseCurrent camera instead of Workspace.camera
while Camera.FieldOfView > 30 do -- Repeat this WHILE FieldOfView is greater then 30 or when keyword break is used
Camera.FieldOfView = Camera.FieldOfWiew - 1 -- This will set fieldOfView to the same value minus 1
game:GetService("RunService").RenderStepped:Wait() -- Use this since we are updating the camera
end --End the loop. Everything udnerneath here is run normally when this loop has ended
Also, seems like you mean “How to lower the value Automatically instead of manually”
Hi! Sorry for the late reply, But I found a decent way to do this. (Sorry that I’m not doing the regular code format, For some reason it wouldn’t work.)
local stop = false
while true do
wait ()
if stop == false then
workspace.Camera.FieldOfView = workspace.Camera.FieldOfView - 1
if workspace.Camera.FieldOfView < 30 then --Change the 30 to when you want it to stop.
stop = true
end
end
end
what it’s doing here is taking the FOV down by 1 every time, And it always checks if the FOV is less than 30, (Or whatever you change it to) it will change the stop variable to true, Which will stop the code.