Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Help changing FOV?

Asked by 8 years ago

So I have script that changes the FOV on touch. The only thing I want it to do is to change the fov gradually and smoothly instead of suddenly.

enabled = true
function onTouch()
    if not enabled then
        return
    end
    wait(0.1)
game.Workspace.Camera.FieldOfView = 120
enabled = false
end 


script.Parent.Touched:connect(onTouch)  

1 answer

Log in to vote
0
Answered by 8 years ago
enabled = true
function onTouch()
    if not enabled then
        return
    end
    wait(0.1)
local target = 120

if game.Workspace.Camera.FieldOfView > target then
    repeat wait(.3)
         game.Workspace.Camera.FieldOfView = game.Workspace.Camera.FieldOfView - 1
    until game.Workspace.Camera.FieldOfView = target
else
    repeat wait(.3) 
        game.Workspace.Camera.FieldOfView = game.Workspace.Camera.FieldOfView + 1
    until game.Workspace.Camera.FieldOfView = target
end

enabled = false
end 


script.Parent.Touched:connect(onTouch)  
Ad

Answer this question