Advertisement
pandasrules

thinggggg

Jun 3rd, 2019
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.80 KB | None | 0 0
  1. --- script by meguy1 ---
  2.  
  3. wait(0.5)
  4.  
  5. --change this to the key you want
  6. activationKey = Enum.KeyCode.LeftControl
  7. secondaryActivationKey = Enum.KeyCode.Y
  8. maxZoom = 20 --zoom amount (less is more)
  9. speed = 0.2 --speed of zoom (from 0 to 1, exclusive)
  10.  
  11.  
  12. runService = game:GetService("RunService")
  13. initialFOV = workspace.CurrentCamera.FieldOfView
  14. zoom = false
  15. zoomInConnection = nil
  16. zoomOutConnection = nil
  17.  
  18. zoomInAnim = function()
  19. local currentZoom = workspace.CurrentCamera.FieldOfView
  20. if zoomOutConnection then
  21. zoomOutConnection:disconnect()
  22. end
  23. zoomInConnection = runService.RenderStepped:connect(function()
  24. if not zoom or math.abs(workspace.CurrentCamera.FieldOfView - maxZoom) < 0.5 then
  25. zoomInConnection:disconnect()
  26. end
  27. workspace.CurrentCamera.FieldOfView = currentZoom
  28. currentZoom = (currentZoom*(1-speed) + maxZoom*speed)
  29. end)
  30. end
  31.  
  32. zoomOutAnim = function()
  33. local currentZoom = workspace.CurrentCamera.FieldOfView
  34. if zoomInConnection then
  35. zoomInConnection:disconnect()
  36. end
  37. zoomOutConnection = runService.RenderStepped:connect(function()
  38. if zoom or math.abs(workspace.CurrentCamera.FieldOfView - initialFOV) < 0.5 then
  39. zoomOutConnection:disconnect()
  40. end
  41. workspace.CurrentCamera.FieldOfView = currentZoom
  42. currentZoom = (currentZoom*(1-speed) + initialFOV*speed)
  43. end)
  44. end
  45.  
  46. function onKeyPress(actionName, userInputState, inputObject)
  47. if userInputState == Enum.UserInputState.Begin then
  48. zoom = true
  49. coroutine.resume(coroutine.create(zoomInAnim))
  50. elseif userInputState == Enum.UserInputState.End then
  51. zoom = false
  52. coroutine.resume(coroutine.create(zoomOutAnim))
  53. end
  54. end
  55.  
  56. game.ContextActionService:BindAction("keyPress", onKeyPress, false, activationKey)
  57. game.ContextActionService:BindAction("keyPress2", onKeyPress, false, secondaryActivationKey)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement