Advertisement
void12

ro beats script

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