Roblox_Scripts204

RoBeats Script

Nov 17th, 2024
2,605
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 6.40 KB | Source Code | 0 0
  1. local keys = shared.keys or {} -- MAKE THIS YOUR ROBEATS KEYBINDS FROM LEFT TO RIGHT, OR SET IN SHARED.KEYS
  2. local autoGrabKeys = shared.autoGrabKeys ~= nil and shared.autoGrabKeys or true
  3.  
  4. local VirtualInputManager = game:GetService("VirtualInputManager")
  5. local camera = workspace.CurrentCamera
  6.  
  7. local Autoplayer = {
  8.     noteY = 3879,
  9.     sliderY = 3878,
  10.     laneDistanceThreshold = 25,
  11.     distanceLowerBound = 0.2,
  12.     distanceUpperBound = 0.6,
  13.     delayLowerBound = 0.03,
  14.     delayUpperBound = 0.05,
  15.     sliderDebounce = 0.06,
  16.     random = Random.new(),
  17.     pressedLanes = {},
  18.     heldLanes = {},
  19.     currentLanePositionsIndex = nil,
  20.     lanePositions = {
  21.         {
  22.             Vector3.new(-309.00, 387.70, -181.09),
  23.             Vector3.new(-306.87, 387.70, -178.56),
  24.             Vector3.new(-304.53, 387.70, -176.21),
  25.             Vector3.new(-301.99, 387.70, -174.08)
  26.         },
  27.  
  28.         {
  29.             Vector3.new(-301.99, 387.70, -235.64),
  30.             Vector3.new(-304.53, 387.70, -233.51),
  31.             Vector3.new(-306.87, 387.70, -231.16),
  32.             Vector3.new(-309.00, 387.70, -228.60)
  33.         },
  34.  
  35.         {
  36.             Vector3.new(-247.44, 387.70, -228.63),
  37.             Vector3.new(-249.57, 387.70, -231.16),
  38.             Vector3.new(-251.92, 387.70, -233.51),
  39.             Vector3.new(-254.46, 387.70, -235.64)
  40.         },
  41.  
  42.         {
  43.             Vector3.new(-254.46, 387.70, -174.08),
  44.             Vector3.new(-251.92, 387.70, -176.21),
  45.             Vector3.new(-249.57, 387.70, -178.56),
  46.             Vector3.new(-247.44, 387.70, -181.09)
  47.         }
  48.     }
  49. }
  50.  
  51. local function UpdateLanePositions()
  52.     local nearestDistance = Autoplayer.laneDistanceThreshold
  53.     local nearestGroupIndex
  54.  
  55.     for groupIndex, groupPositions in next, Autoplayer.lanePositions do
  56.         local distance = (groupPositions[1] - camera.CFrame.Position).Magnitude
  57.  
  58.         if distance < nearestDistance then
  59.             nearestDistance = distance
  60.             nearestGroupIndex = groupIndex
  61.         end
  62.     end
  63.  
  64.     Autoplayer.currentLanePositionsIndex = nearestGroupIndex
  65. end
  66.  
  67. local function GetNearestLane(position)
  68.     UpdateLanePositions()
  69.    
  70.     local nearestDistance = Autoplayer.laneDistanceThreshold
  71.     local nearestLane
  72.  
  73.     for laneIndex, lanePosition in next, Autoplayer.lanePositions[Autoplayer.currentLanePositionsIndex] do
  74.         local distance = (lanePosition - position).Magnitude
  75.  
  76.         if distance < nearestDistance then
  77.             nearestDistance = distance
  78.             nearestLane = { laneIndex, lanePosition}
  79.         end
  80.     end
  81.  
  82.     if not nearestLane then
  83.         return
  84.     end
  85.  
  86.     return nearestLane[1], nearestLane[2]
  87. end
  88.  
  89. local function GrabKeys()
  90.     if not autoGrabKeys or #keys == 4 then
  91.         return
  92.     end
  93.    
  94.     for _, child in next, workspace:GetChildren() do
  95.         if child:FindFirstChild("ControlPopup") then
  96.             for _, descendant in next, child:GetChildren() do
  97.                 if descendant.Name == "ControlPopup" then
  98.                     local popupLane = GetNearestLane(descendant.Position)
  99.                    
  100.                     if popupLane then
  101.                         keys[popupLane] = descendant.SurfaceGui.Frame.Letter.Text
  102.                     end
  103.                 end
  104.             end
  105.         end
  106.     end
  107. end
  108.  
  109. for index, instance in next, workspace:GetDescendants() do
  110.     if instance.ClassName == "CylinderHandleAdornment" then
  111.         instance:GetPropertyChangedSignal("CFrame"):Connect(function()
  112.             GrabKeys()
  113.  
  114.             if instance.Transparency == 0 and math.floor(instance.CFrame.Y * 10) == Autoplayer.noteY 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.Position.X - lanePosition.X
  120.  
  121.                     if Autoplayer.currentLanePositionsIndex > 2 then
  122.                         distance = math.abs(distance)
  123.                     end
  124.  
  125.                     if not Autoplayer.pressedLanes[noteLane] and distance <= randomDistance then
  126.                         Autoplayer.pressedLanes[noteLane] = true
  127.  
  128.                         VirtualInputManager:SendKeyEvent(true, keys[noteLane], false, game)
  129.                         task.wait(Autoplayer.random:NextNumber(Autoplayer.delayLowerBound, Autoplayer.delayUpperBound))
  130.                         VirtualInputManager:SendKeyEvent(false, keys[noteLane], false, game)
  131.  
  132.                         Autoplayer.pressedLanes[noteLane] = false
  133.                     end
  134.                 end
  135.             elseif instance.Transparency < 1 and instance.Height > 0.2 and math.floor(instance.CFrame.Y * 10) == Autoplayer.sliderY then
  136.                 local noteLane, lanePosition = GetNearestLane(instance.CFrame.Position)
  137.  
  138.                 if noteLane then
  139.                     local randomDistance = Autoplayer.random:NextNumber(Autoplayer.distanceLowerBound, Autoplayer.distanceUpperBound)
  140.                     local distance = (instance.CFrame - instance.CFrame.LookVector * instance.Height / 2).X - lanePosition.X
  141.  
  142.                     if Autoplayer.currentLanePositionsIndex > 2 then
  143.                         distance = math.abs(distance)
  144.                     end
  145.  
  146.                     if not Autoplayer.heldLanes[noteLane] and distance <= randomDistance then
  147.                         Autoplayer.heldLanes[noteLane] = true
  148.                        
  149.                         VirtualInputManager:SendKeyEvent(true, keys[noteLane], false, game)
  150.                        
  151.                         local noteDistance
  152.  
  153.                         repeat
  154.                             noteDistance = (instance.CFrame + instance.CFrame.LookVector * instance.Height / 2).X - lanePosition.X
  155.  
  156.                             task.wait()
  157.                         until (Autoplayer.currentLanePositionsIndex > 2 and math.abs(noteDistance) or noteDistance) <= randomDistance
  158.                        
  159.                         VirtualInputManager:SendKeyEvent(false, keys[noteLane], false, game)
  160.                        
  161.                         task.wait(Autoplayer.sliderDebounce)
  162.                        
  163.                         Autoplayer.heldLanes[noteLane] = false
  164.                     end
  165.                 end
  166.             end
  167.         end)
  168.     end
  169. end
Advertisement
Add Comment
Please, Sign In to add comment