Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --- script by meguy1 ---
- wait(0.5)
- --change this to the key you want
- activationKey = Enum.KeyCode.LeftControl
- secondaryActivationKey = Enum.KeyCode.Y
- maxZoom = 20 --zoom amount (less is more)
- speed = 0.2 --speed of zoom (from 0 to 1, exclusive)
- runService = game:GetService("RunService")
- initialFOV = workspace.CurrentCamera.FieldOfView
- zoom = false
- zoomInConnection = nil
- zoomOutConnection = nil
- zoomInAnim = function()
- local currentZoom = workspace.CurrentCamera.FieldOfView
- if zoomOutConnection then
- zoomOutConnection:disconnect()
- end
- zoomInConnection = runService.RenderStepped:connect(function()
- if not zoom or math.abs(workspace.CurrentCamera.FieldOfView - maxZoom) < 0.5 then
- zoomInConnection:disconnect()
- end
- workspace.CurrentCamera.FieldOfView = currentZoom
- currentZoom = (currentZoom*(1-speed) + maxZoom*speed)
- end)
- end
- zoomOutAnim = function()
- local currentZoom = workspace.CurrentCamera.FieldOfView
- if zoomInConnection then
- zoomInConnection:disconnect()
- end
- zoomOutConnection = runService.RenderStepped:connect(function()
- if zoom or math.abs(workspace.CurrentCamera.FieldOfView - initialFOV) < 0.5 then
- zoomOutConnection:disconnect()
- end
- workspace.CurrentCamera.FieldOfView = currentZoom
- currentZoom = (currentZoom*(1-speed) + initialFOV*speed)
- end)
- end
- function onKeyPress(actionName, userInputState, inputObject)
- if userInputState == Enum.UserInputState.Begin then
- zoom = true
- coroutine.resume(coroutine.create(zoomInAnim))
- elseif userInputState == Enum.UserInputState.End then
- zoom = false
- coroutine.resume(coroutine.create(zoomOutAnim))
- end
- end
- game.ContextActionService:BindAction("keyPress", onKeyPress, false, activationKey)
- game.ContextActionService:BindAction("keyPress2", onKeyPress, false, secondaryActivationKey)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement