Advertisement
Az_ZaZaAzZAZAZ

Robeats script

Jan 16th, 2023
247
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.64 KB | None | 0 0
  1. local keys = shared.keys or {"Z", "X", "Comma", "Period"} -- MAKE THIS YOUR ROBEATS KEYBINDS FROM LEFT TO RIGHT, OR SET IN SHARED.KEYS
  2.  
  3. local VirtualInputManager = game:GetService("VirtualInputManager")
  4. local camera = workspace.CurrentCamera
  5.  
  6. local Autoplayer = {
  7. noteY = 3879,
  8. sliderY = 3878,
  9. laneDistanceThreshold = 25,
  10. distanceLowerBound = 0.2,
  11. distanceUpperBound = 0.8,
  12. delayLowerBound = 0.03,
  13. delayUpperBound = 0.05,
  14. sliderDebounce = 0.06,
  15. random = Random.new(),
  16. pressedLanes = {},
  17. heldLanes = {},
  18. currentLanePositionsIndex = nil,
  19. lanePositions = {
  20. {
  21. Vector3.new(-309.00, 387.70, -181.09),
  22. Vector3.new(-306.87, 387.70, -178.56),
  23. Vector3.new(-304.53, 387.70, -176.21),
  24. Vector3.new(-301.99, 387.70, -174.08)
  25. },
  26.  
  27. {
  28. Vector3.new(-301.99, 387.70, -235.64),
  29. Vector3.new(-304.53, 387.70, -233.51),
  30. Vector3.new(-306.87, 387.70, -231.16),
  31. Vector3.new(-309.00, 387.70, -228.60)
  32. },
  33.  
  34. {
  35. Vector3.new(-247.44, 387.70, -228.63),
  36. Vector3.new(-249.57, 387.70, -231.16),
  37. Vector3.new(-251.92, 387.70, -233.51),
  38. Vector3.new(-254.46, 387.70, -235.64)
  39. },
  40.  
  41. {
  42. Vector3.new(-254.46, 387.70, -174.08),
  43. Vector3.new(-251.92, 387.70, -176.21),
  44. Vector3.new(-249.57, 387.70, -178.56),
  45. Vector3.new(-247.44, 387.70, -181.09)
  46. }
  47. }
  48. }
  49.  
  50. local function UpdateLanePositions() -- table.sort cant be used here
  51. local nearestDistance = Autoplayer.laneDistanceThreshold
  52. local nearestGroupIndex
  53.  
  54. for groupIndex, groupPositions in next, Autoplayer.lanePositions do
  55. local distance = (groupPositions[1] - camera.CFrame.Position).Magnitude
  56.  
  57. if distance < nearestDistance then
  58. nearestDistance = distance
  59. nearestGroupIndex = groupIndex
  60. end
  61. end
  62.  
  63. Autoplayer.currentLanePositionsIndex = nearestGroupIndex
  64. end
  65.  
  66. local function GetNearestLane(position) -- table.sort cant be used here
  67. UpdateLanePositions()
  68.  
  69. local nearestDistance = Autoplayer.laneDistanceThreshold
  70. local nearestLane
  71.  
  72. for laneIndex, lanePosition in next, Autoplayer.lanePositions[Autoplayer.currentLanePositionsIndex] do
  73. local distance = (lanePosition - position).Magnitude
  74.  
  75. if distance < nearestDistance then
  76. nearestDistance = distance
  77. nearestLane = {laneIndex, lanePosition}
  78. end
  79. end
  80.  
  81. if not nearestLane then
  82. return
  83. end
  84.  
  85. return nearestLane[1], nearestLane[2]
  86. end
  87.  
  88. for index, instance in next, workspace:GetDescendants() do
  89. if instance.ClassName == "CylinderHandleAdornment" then
  90. instance:GetPropertyChangedSignal("CFrame"):Connect(function()
  91. if instance.Transparency == 0 and math.floor(instance.CFrame.Y * 10) == Autoplayer.noteY then
  92. local noteLane, lanePosition = GetNearestLane(instance.CFrame.Position)
  93.  
  94. if noteLane then
  95. local randomDistance = Autoplayer.random:NextNumber(Autoplayer.distanceLowerBound, Autoplayer.distanceUpperBound)
  96. local distance = instance.CFrame.Position.X - lanePosition.X
  97.  
  98. if Autoplayer.currentLanePositionsIndex > 2 then
  99. distance = math.abs(distance)
  100. end
  101.  
  102. if not Autoplayer.pressedLanes[noteLane] and distance <= randomDistance then
  103. Autoplayer.pressedLanes[noteLane] = true
  104.  
  105. VirtualInputManager:SendKeyEvent(true, keys[noteLane], false, game)
  106. task.wait(Autoplayer.random:NextNumber(Autoplayer.delayLowerBound, Autoplayer.delayUpperBound))
  107. VirtualInputManager:SendKeyEvent(false, keys[noteLane], false, game)
  108.  
  109. Autoplayer.pressedLanes[noteLane] = false
  110. end
  111. end
  112. elseif instance.Transparency < 1 and instance.Height > 0.2 and math.floor(instance.CFrame.Y * 10) == Autoplayer.sliderY then
  113. local noteLane, lanePosition = GetNearestLane(instance.CFrame.Position)
  114.  
  115. if noteLane then
  116. local randomDistance = Autoplayer.random:NextNumber(Autoplayer.distanceLowerBound, Autoplayer.distanceUpperBound)
  117. local distance = (instance.CFrame - instance.CFrame.LookVector * instance.Height / 2).X - lanePosition.X
  118.  
  119. if Autoplayer.currentLanePositionsIndex > 2 then
  120. distance = math.abs(distance)
  121. end
  122.  
  123. if not Autoplayer.heldLanes[noteLane] and distance <= randomDistance then
  124. Autoplayer.heldLanes[noteLane] = true
  125.  
  126. VirtualInputManager:SendKeyEvent(true, keys[noteLane], false, game)
  127.  
  128. repeat
  129. task.wait() -- ugly but whatever
  130. until (Autoplayer.currentLanePositionsIndex > 2 and math.abs((instance.CFrame + instance.CFrame.LookVector * instance.Height / 2).X - lanePosition.X) or (instance.CFrame + instance.CFrame.LookVector * instance.Height / 2).X - lanePosition.X) <= randomDistance
  131.  
  132. VirtualInputManager:SendKeyEvent(false, keys[noteLane], false, game)
  133.  
  134. task.wait(Autoplayer.sliderDebounce)
  135.  
  136. Autoplayer.heldLanes[noteLane] = false
  137. end
  138. end
  139. end
  140. end)
  141. end
  142. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement