Saffwat
(Safwart)
March 25, 2023, 3:38pm
1
i want it to tween the camera to (fov amount here) -= camera.FieldOfView
but make it so that the player cant change that fov
zoomEvent.OnClientEvent:Connect(function(zoom, duration)
print("zoom")
local zoommin = game.TweenService:Create(player,TweenInfo.new(0.2),{CameraMinZoomDistance = zoom})
local zoommax = game.TweenService:Create(player,TweenInfo.new(0.2),{CameraMaxZoomDistance = zoom})
zoommin:Play()
zoommax:Play()
task.wait(duration)
zoommin = game.TweenService:Create(player,TweenInfo.new(0.2),{CameraMinZoomDistance = 0.5})
zoommax = game.TweenService:Create(player,TweenInfo.new(0.2),{CameraMaxZoomDistance = 50})
zoommin:Play()
zoommax:Play()
end)
Quamocl
(Quintin)
March 25, 2023, 3:43pm
2
To tween the camera’s FieldOfView property instead of CameraMinZoomDistance and CameraMaxZoomDistance, you can modify the code as follows:
zoomEvent.OnClientEvent:Connect(function(zoom, duration)
print("zoom")
local originalFOV = workspace.CurrentCamera.FieldOfView
local targetFOV = originalFOV - zoom
local fovTween = game.TweenService:Create(workspace.CurrentCamera, TweenInfo.new(duration), {FieldOfView = targetFOV})
fovTween:Play()
task.wait(duration)
fovTween = game.TweenService:Create(workspace.CurrentCamera, TweenInfo.new(0.2), {FieldOfView = originalFOV})
fovTween:Play()
end)
This code stores the current FieldOfView property in a variable called originalFOV, calculates the target FieldOfView by subtracting the zoom value from the originalFOV, creates a tween using the target FieldOfView, and then waits for the duration of the tween before creating another tween to restore the originalFOV. The player will not be able to change the FieldOfView during the tweening process.