--// SERVICES
local Players = game:GetService("Players")
local player = Players.LocalPlayer
--// VARIABLES
local running = false
local folder = workspace:WaitForChild("_LocalCollectableObjects")
--// GET ROOT
local function getRoot()
local char = player.Character or player.CharacterAdded:Wait()
return char:WaitForChild("HumanoidRootPart")
end
--// SORT CLOSE → FAR
local function getSortedObjects()
local root = getRoot()
local objs = {}
for _, v in pairs(folder:GetChildren()) do
if v:IsA("BasePart") then
table.insert(objs, v)
elseif v:FindFirstChildWhichIsA("BasePart") then
table.insert(objs, v:FindFirstChildWhichIsA("BasePart"))
end
end
table.sort(objs, function(a, b)
return (a.Position - root.Position).Magnitude < (b.Position - root.Position).Magnitude
end)
return objs
end
--// TP LOOP
task.spawn(function()
while true do
if running then
local root = getRoot()
local sorted = getSortedObjects()
for _, obj in ipairs(sorted) do
if not running then break end
if obj and obj.Parent then
root.CFrame = obj.CFrame
task.wait(0.02) -- VERY FAST (adjust if needed)
end
end
end
task.wait()
end
end)
--// GUI
local gui = Instance.new("ScreenGui")
gui.Name = "OpenSourceGUI"
gui.Parent = game.CoreGui
local frame = Instance.new("Frame")
frame.Size = UDim2.new(0, 200, 0, 120)
frame.Position = UDim2.new(0.4, 0, 0.4, 0)
frame.BackgroundColor3 = Color3.fromRGB(25,25,25)
frame.Active = true
frame.Draggable = true
frame.Parent = gui
local title = Instance.new("TextLabel")
title.Size = UDim2.new(1,0,0,30)
title.Text = "Made by _OpenSource_"
title.TextColor3 = Color3.new(1,1,1)
title.BackgroundTransparency = 1
title.Parent = frame
local button = Instance.new("TextButton")
button.Size = UDim2.new(0.8,0,0,40)
button.Position = UDim2.new(0.1,0,0.4,0)
button.Text = "Auto TP: OFF"
button.BackgroundColor3 = Color3.fromRGB(40,40,40)
button.TextColor3 = Color3.new(1,1,1)
button.Parent = frame
--// TOGGLE
button.MouseButton1Click:Connect(function()
running = not running
button.Text = running and "Auto TP: ON" or "Auto TP: OFF"
end)