Advertisement
Legend_HandlesYT

Untitled

Feb 28th, 2022
1,546
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.16 KB | None | 0 0
  1. local tabDown = false
  2. local input = game:GetService('UserInputService')
  3. local player = game.Players.LocalPlayer
  4. local camera = game.Workspace.CurrentCamera
  5. local character = player.Character
  6. local head = character.Head
  7. local torso = character.Torso
  8. pos = Vector3.new(0,0,0)
  9. local rs = game:GetService('RunService')
  10. isdoing = false
  11.  
  12. cor = coroutine.create(function()
  13. while wait() do
  14. if tabDown and I == 0 then
  15. local pos = head.Position
  16. local partyGoal = findGoal(head.Position)
  17. local lookAt = partyGoal.Position + Vector3.new(0,85,0)
  18. local mag = (character.PrimaryPart.Position - partyGoal.Position).magnitude
  19. local cameraCFrame = CFrame.new(pos, lookAt)
  20. camera.CFrame = cameraCFrame
  21. I = I + 1
  22. rs.RenderStepped:Wait()
  23. I = I - 1
  24. if isdoing == false then
  25. coroutine.yield()
  26. end
  27. end
  28. end
  29.  
  30.  
  31.  
  32. end)
  33.  
  34. function findGoal(position)
  35. local nearestGoal = nil
  36. local lowest = math.huge
  37. for i,v in pairs(game.Workspace:GetDescendants()) do
  38. if v.Name == 'Goal' and v:IsA('Part') then
  39. local distance = (torso.Position - v.Position).magnitude
  40. if distance < lowest then
  41. lowest = distance
  42. Goal = v
  43. end
  44. end
  45. end
  46. return Goal
  47. end
  48.  
  49. input.InputBegan:Connect(function(key, gpe)
  50. local xkey = key.KeyCode
  51. if xkey == Enum.KeyCode.X then
  52. tabDown = true
  53. if isdoing == false then
  54. wait()
  55. isdoing = true
  56. coroutine.resume(cor)
  57. end
  58. end
  59. end)
  60.  
  61. input.InputEnded:Connect(function(key, gpe)
  62. local xkey = key.KeyCode
  63. if xkey == Enum.KeyCode.X then
  64. tabDown = false
  65. if isdoing then
  66. isdoing = false
  67. end
  68. end
  69. end)
  70. I = 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement