-- FAST TREASURE CHEST FARM
local Players = game:GetService("Players")
local player = Players.LocalPlayer
local char = player.Character or player.CharacterAdded:Wait()
local root = char:WaitForChild("HumanoidRootPart")
local opened = {}
local chests = {}
-- detect new chests instantly
workspace.DescendantAdded:Connect(function(v)
if v.Name == "TreasureChest" then
table.insert(chests, v)
end
end)
-- initial chest load
for _,v in pairs(workspace:GetDescendants()) do
if v.Name == "TreasureChest" then
table.insert(chests, v)
end
end
local function getClosestChest()
local closest
local dist = math.huge
for _,chest in pairs(chests) do
if chest and not opened[chest] then
local part = chest:FindFirstChildWhichIsA("BasePart", true)
if part then
local d = (root.Position - part.Position).Magnitude
if d < dist then
dist = d
closest = chest
end
end
end
end
return closest
end
while true do
task.wait(0.15)
local chest = getClosestChest()
if chest then
local part = chest:FindFirstChildWhichIsA("BasePart", true)
local prompt = chest:FindFirstChildWhichIsA("ProximityPrompt", true)
if part and prompt then
opened[chest] = true
root.CFrame = part.CFrame + Vector3.new(0,3,0)
prompt.HoldDuration = 0
fireproximityprompt(prompt)
-- collect nearby drops
task.wait(0.2)
for _,v in pairs(workspace:GetDescendants()) do
if v:IsA("ProximityPrompt") then
local p = v.Parent
if p and p:IsA("BasePart") then
if (root.Position - p.Position).Magnitude < 10 then
fireproximityprompt(v)
end
end
end
end
end
end
end
Comments
Very laggy, don't use it.