Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local Player = game.Players.LocalPlayer
- local RunService = game:GetService("RunService")
- local Pathfinding = game:GetService("PathfindingService")
- local ImpossibleItems = {}
- function RemoveFromTable(Table, Item)
- for i, TItem in pairs(ImpossibleItems) do
- if TItem == Item then
- table.remove(Table, i)
- break
- end
- end
- end
- function AutoGrab()
- RunService.Heartbeat:Connect(function()
- if Player.Character and Player.Character:FindFirstChild("HumanoidRootPart") then
- local Root = Player.Character.HumanoidRootPart
- for i, c in pairs(workspace.DroppedItems:GetChildren()) do
- if not (c.Name == "StellaStar") and not (c.Name == "StellasStar") then
- if c.Name == "Coin" or c.Name == "Gilded Coin" then
- fireproximityprompt(c:FindFirstChildOfClass("ProximityPrompt"))
- elseif c:FindFirstChild("Casing") then
- fireproximityprompt(c.Casing:FindFirstChildOfClass("ProximityPrompt"))
- end
- end
- end
- end
- end)
- end
- local function FollowPath(Destination, Item)
- local Character = Player.Character
- if Character then
- local Path = Pathfinding:CreatePath()
- local Success, Error = pcall(function()
- Path:ComputeAsync(Character.Torso.Position, Destination)
- end)
- if Success and Path.Status == Enum.PathStatus.Success then
- if table.find(ImpossibleItems, Item) then
- RemoveFromTable(ImpossibleItems, Item)
- end
- local Waypoints = Path:GetWaypoints()
- for i, Waypoint in pairs(Waypoints) do
- if Waypoint.Action == Enum.PathWaypointAction.Jump then
- Character.Humanoid:ChangeState(Enum.HumanoidStateType.Jumping)
- end
- Character.Humanoid:MoveTo(Waypoint.Position)
- Character.Humanoid.MoveToFinished:Wait(2)
- end
- else
- if not table.find(ImpossibleItems, Item) then
- table.insert(ImpossibleItems, Item)
- end
- end
- end
- end
- local function GetNearestItem()
- local Character = Player.Character
- if Character then
- local NearestDistance
- local NearestItem
- for i, Item in pairs(workspace.DroppedItems:GetChildren()) do
- if not (Item.Name == "StellaStar") and not (Item.Name == "StellasStar") then
- local Root
- if Item.Name == "Coin" or Item.Name == "Gilded Coin" then
- Root = Item
- elseif Item:FindFirstChild("Casing")
- Root = Item:WaitForChild("Casing")
- end
- if not Root then return nil end
- if not table.find(ImpossibleItems, Item) then
- if NearestDistance then
- if (Character.Torso.Position - Root.Position).magnitude < NearestDistance then
- NearestDistance = (Character.Torso.Position - Root.Position).magnitude
- NearestItem = Item
- end
- else
- NearestDistance = (Character.Torso.Position - Root.Position).magnitude
- NearestItem = Item
- end
- end
- else
- return nil
- end
- end
- return NearestItem
- else
- return nil
- end
- end
- task.spawn(AutoGrab)
- while task.wait() do
- local Item = GetNearestItem()
- if Item then
- local Root
- if Item.Name == "Coin" or Item.Name == "Gilded Coin" then
- Root = Item
- else
- Root = Item:WaitForChild("Casing")
- end
- if Root then
- local Highlight = Instance.new("Highlight")
- Highlight.Parent = Root
- Highlight.FillTransparency = 0
- FollowPath(Root.Position, Item)
- Highlight:Destroy()
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement