Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local UserInputService = game:GetService("UserInputService")
- local Camera = workspace.CurrentCamera
- local defaultFOV = 70
- local zoomedInFOV = 25
- local extraZoomedFOV = 5
- local zoomSpeed = 0.2
- local sensitivitySpeed = 0.1
- local defaultSensitivity = UserInputService.MouseDeltaSensitivity
- local zoomedSensitivity = 0.5
- local extraZoomedSensitivity = 0.2
- local zoomLevel = 0
- local function smoothZoom(targetFOV)
- local currentFOV = Camera.FieldOfView
- while math.abs(currentFOV - targetFOV) > 0.1 do
- currentFOV = currentFOV + (targetFOV - currentFOV) * zoomSpeed
- Camera.FieldOfView = currentFOV
- task.wait()
- end
- Camera.FieldOfView = targetFOV
- end
- local function smoothSensitivity(targetSensitivity)
- local currentSensitivity = UserInputService.MouseDeltaSensitivity
- while math.abs(currentSensitivity - targetSensitivity) > 0.01 do
- currentSensitivity = currentSensitivity + (targetSensitivity - currentSensitivity) * sensitivitySpeed
- UserInputService.MouseDeltaSensitivity = currentSensitivity
- task.wait()
- end
- UserInputService.MouseDeltaSensitivity = targetSensitivity
- end
- UserInputService.InputBegan:Connect(function(input, gameProcessed)
- if not gameProcessed and input.KeyCode == Enum.KeyCode.E then
- zoomLevel = (zoomLevel + 1) % 3
- local targetFOV, targetSensitivity
- if zoomLevel == 0 then
- targetFOV = defaultFOV
- targetSensitivity = defaultSensitivity
- elseif zoomLevel == 1 then
- targetFOV = zoomedInFOV
- targetSensitivity = zoomedSensitivity
- elseif zoomLevel == 2 then
- targetFOV = extraZoomedFOV
- targetSensitivity = extraZoomedSensitivity
- end
- task.spawn(smoothZoom, targetFOV)
- task.spawn(smoothSensitivity, targetSensitivity)
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement