Advertisement
ProScripter29

Auto Collect Sol's RNG

May 5th, 2024 (edited)
296
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.26 KB | None | 0 0
  1. local Player = game.Players.LocalPlayer
  2.  
  3. local RunService = game:GetService("RunService")
  4.  
  5. local Pathfinding = game:GetService("PathfindingService")
  6.  
  7. local ImpossibleItems = {}
  8.  
  9. function RemoveFromTable(Table, Item)
  10. for i, TItem in pairs(ImpossibleItems) do
  11. if TItem == Item then
  12. table.remove(Table, i)
  13. break
  14. end
  15. end
  16. end
  17.  
  18. function AutoGrab()
  19. RunService.Heartbeat:Connect(function()
  20. if Player.Character and Player.Character:FindFirstChild("HumanoidRootPart") then
  21. local Root = Player.Character.HumanoidRootPart
  22. for i, c in pairs(workspace.DroppedItems:GetChildren()) do
  23. if not (c.Name == "StellaStar") and not (c.Name == "StellasStar") then
  24. if c.Name == "Coin" or c.Name == "Gilded Coin" then
  25. fireproximityprompt(c:FindFirstChildOfClass("ProximityPrompt"))
  26. elseif c:FindFirstChild("Casing") then
  27. fireproximityprompt(c.Casing:FindFirstChildOfClass("ProximityPrompt"))
  28. end
  29. end
  30. end
  31. end
  32. end)
  33. end
  34.  
  35. local function FollowPath(Destination, Item)
  36. local Character = Player.Character
  37. if Character then
  38. local Path = Pathfinding:CreatePath()
  39. local Success, Error = pcall(function()
  40. Path:ComputeAsync(Character.Torso.Position, Destination)
  41. end)
  42. if Success and Path.Status == Enum.PathStatus.Success then
  43. if table.find(ImpossibleItems, Item) then
  44. RemoveFromTable(ImpossibleItems, Item)
  45. end
  46. local Waypoints = Path:GetWaypoints()
  47. for i, Waypoint in pairs(Waypoints) do
  48. if Waypoint.Action == Enum.PathWaypointAction.Jump then
  49. Character.Humanoid:ChangeState(Enum.HumanoidStateType.Jumping)
  50. end
  51. Character.Humanoid:MoveTo(Waypoint.Position)
  52. Character.Humanoid.MoveToFinished:Wait(2)
  53. end
  54. else
  55. if not table.find(ImpossibleItems, Item) then
  56. table.insert(ImpossibleItems, Item)
  57. end
  58. end
  59. end
  60. end
  61.  
  62. local function GetNearestItem()
  63. local Character = Player.Character
  64. if Character then
  65. local NearestDistance
  66. local NearestItem
  67. for i, Item in pairs(workspace.DroppedItems:GetChildren()) do
  68. if not (Item.Name == "StellaStar") and not (Item.Name == "StellasStar") then
  69. local Root
  70. if Item.Name == "Coin" or Item.Name == "Gilded Coin" then
  71. Root = Item
  72. elseif Item:FindFirstChild("Casing")
  73. Root = Item:WaitForChild("Casing")
  74. end
  75. if not Root then return nil end
  76. if not table.find(ImpossibleItems, Item) then
  77. if NearestDistance then
  78. if (Character.Torso.Position - Root.Position).magnitude < NearestDistance then
  79. NearestDistance = (Character.Torso.Position - Root.Position).magnitude
  80. NearestItem = Item
  81. end
  82. else
  83. NearestDistance = (Character.Torso.Position - Root.Position).magnitude
  84. NearestItem = Item
  85. end
  86. end
  87. else
  88. return nil
  89. end
  90. end
  91. return NearestItem
  92. else
  93. return nil
  94. end
  95. end
  96.  
  97. task.spawn(AutoGrab)
  98.  
  99. while task.wait() do
  100. local Item = GetNearestItem()
  101. if Item then
  102. local Root
  103. if Item.Name == "Coin" or Item.Name == "Gilded Coin" then
  104. Root = Item
  105. else
  106. Root = Item:WaitForChild("Casing")
  107. end
  108. if Root then
  109. local Highlight = Instance.new("Highlight")
  110. Highlight.Parent = Root
  111. Highlight.FillTransparency = 0
  112. FollowPath(Root.Position, Item)
  113. Highlight:Destroy()
  114. end
  115. end
  116. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement