Advertisement
Guest User

Untitled

a guest
Aug 17th, 2019
4,092
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.04 KB | None | 0 0
  1. -- DEFAULT THIRD PERSON PERSPECTIVE --
  2. local reset = false
  3. local RunService = game:GetService("RunService")
  4.  
  5. -- Variables for the camera and player
  6. local camera = workspace.CurrentCamera
  7. local player = game.Players.LocalPlayer
  8. local disable = false
  9.  
  10. local CAMERA_OFFSET = Vector3.new(-1,22,0)
  11.  
  12. -- Enables the camera to do what this script says
  13. camera.CameraType = Enum.CameraType.Scriptable
  14.  
  15. -- Called every time the screen refreshes
  16. local function onRenderStep()
  17. -- Check the player's character has spawned
  18. if player.Character then
  19. local playerPosition = player.Character:WaitForChild("HumanoidRootPart").Position
  20. local cameraPosition = playerPosition + CAMERA_OFFSET
  21.  
  22. -- make the camera follow the player
  23. camera.CoordinateFrame = CFrame.new(cameraPosition, playerPosition)
  24. end
  25. end
  26.  
  27. RunService:BindToRenderStep("Camera", Enum.RenderPriority.Camera.Value, onRenderStep)
  28.  
  29.  
  30. -- TOGGLE TO FIRST PERSON PERSPECTIVE --
  31. fp = false
  32. player.CameraMode = "Classic"
  33. player.CameraMaxZoomDistance = 22
  34. player.CameraMinZoomDistance = 22
  35.  
  36. local UserInputService = game:GetService("UserInputService")
  37. UserInputService.InputBegan:Connect(function(input, gameProcessed)
  38. if input.UserInputType == Enum.UserInputType.MouseButton2 then
  39. if disable == false then
  40. if fp == false then
  41. player.CameraMode = "LockFirstPerson"
  42. game:GetService("RunService"):UnbindFromRenderStep("Camera")
  43. game.Players.LocalPlayer.Character.Humanoid.WalkSpeed = 0
  44. game.Players.LocalPlayer.Character.Humanoid.JumpPower = 0
  45. fp = true
  46. elseif input.UserInputType == Enum.UserInputType.MouseButton2 then
  47. if disable == false then
  48. if fp then
  49. RunService:BindToRenderStep("Camera", Enum.RenderPriority.Camera.Value, onRenderStep)
  50. player.CameraMode = "Classic"
  51. game.Players.LocalPlayer.Character.Humanoid.WalkSpeed = 14
  52. game.Players.LocalPlayer.Character.Humanoid.JumpPower = 17
  53. fp = false
  54. end
  55. end
  56. end
  57. end
  58. end
  59. end)
  60.  
  61. plr = game:GetService("Players").LocalPlayer
  62. plr.Character:WaitForChild("Humanoid").Died:Connect(function()
  63. if fp == true then
  64. print("fp is true")
  65. disable = true
  66. RunService:BindToRenderStep("Camera", Enum.RenderPriority.Camera.Value, onRenderStep)
  67. player.CameraMode = "Classic"
  68. plr.CharacterAdded:Wait()
  69. fp = false
  70. disable = false
  71. end
  72. end)
  73.  
  74.  
  75. plr = game:GetService("Players").LocalPlayer
  76. plr.Character:WaitForChild("Humanoid").Died:Connect(function()
  77. if fp == false then
  78. print("fp = false")
  79. disable = true
  80. plr.CharacterAdded:Wait()
  81. fp = false
  82. disable = false
  83. end
  84. end)
  85.  
  86. plr = game:GetService("Players").LocalPlayer
  87. plr.Character:WaitForChild("Humanoid").Died:Connect(function()
  88. if fp == true then
  89. print("fp is true")
  90. disable = true
  91. RunService:BindToRenderStep("Camera", Enum.RenderPriority.Camera.Value, onRenderStep)
  92. player.CameraMode = "Classic"
  93. plr.CharacterAdded:Wait()
  94. fp = false
  95. disable = false
  96. end
  97. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement