for _, focusName in pairs(DefaultFarmFocusList) do
local function UpdateButton(text, interact)
if not FarmFocusListButtons[focusName] then return end
while true do
wait()
FarmFocusListButtons[focusName]:Set(text, interact)
break
end
end
FarmFocusListButtons[focusName] = autoFarmTab:CreateButton({
Name = focusName,
SectionParent = farmPreferences,
Interact = table.find(FarmFocusList, focusName) and "Remove" or "Add",
CurrentValue = false,
Callback = function(Value)
if table.find(FarmFocusList, focusName) then
table.remove(FarmFocusList, table.find(FarmFocusList, focusName))
-- UpdateButton(nil, "Add")
else
table.insert(FarmFocusList, focusName)
-- UpdateButton(nil, "Remove")
end
coroutine.wrap(function()
while true do
wait()
UpdateFarmFocusUI()
break
end
end)
SaveCustomFlag("AutoFarm_FarmFocusList", FarmFocusList)
end
})
-- FarmFocusListButtons[focusName]:Disable("Coming soon")
end
AddCustomFlag("AutoFarm_FarmFocusList", {}, function(newTable)
FarmFocusList = newTable
local hasChanges = false
for i, v in pairs(FarmFocusList) do
if not table.find(DefaultFarmFocusList, v) then
table.remove(FarmFocusList, i)
hasChanges = true
end
end
if hasChanges then
coroutine.wrap(function()
wait()
SaveCustomFlag("AutoFarm_FarmFocusList", FarmFocusList)
end)
end
UpdateFarmFocusUI()
end)
local farmUtilities = autoFarmTab:CreateSection("Farm Utilities", false, true)
local FarmUtilities_CollectDrops = false
local FarmUtilities_CurrentOrbs = {}
autoFarmTab:CreateToggle({
Name = "Collect Drops",
SectionParent = farmUtilities,
CurrentValue = false,
Flag = "FarmUtilities_CollectDrops",
Callback = function(Value)
FarmUtilities_CollectDrops = Value
if Value then
table.clear(FarmUtilities_CurrentOrbs)
FarmUtilities_CurrentOrbs = {}
CollectAllOrbs()
CollectAllLootbags()
end
if not FarmUtilities_CollectDrops then return end
task.spawn(function()
while FarmUtilities_CollectDrops do
wait(0.05)
if not FarmUtilities_CollectDrops then break end
if FarmUtilities_CurrentOrbs and #FarmUtilities_CurrentOrbs > 0 then
Library.Network.Fire("Claim Orbs", FarmUtilities_CurrentOrbs)
table.clear(FarmUtilities_CurrentOrbs)
FarmUtilities_CurrentOrbs = {}
end
end
end)
end
})
function CollectAllOrbs()
pcall(function()
local OrbsToCollect = {}
for orbId, orb in pairs(Library.Things:FindFirstChild("Orbs"):GetChildren()) do
if not FarmUtilities_CollectDrops then break end
if orbId and orb then
table.insert(OrbsToCollect, orb.Name)
end
end
if OrbsToCollect and #OrbsToCollect > 0 and FarmUtilities_CollectDrops then
Library.Network.Fire("Claim Orbs", OrbsToCollect)
end
end)
end
function CollectAllLootbags()
pcall(function()
for _, lootbag in pairs(Library.Things:FindFirstChild("Lootbags"):GetChildren()) do
if not FarmUtilities_CollectDrops then break end
if lootbag and not lootbag:GetAttribute("Collected") then
Library.Network.Fire("Collect Lootbag", lootbag.Name, HumanoidRootPart.Position + Vector3.new(math.random(-0.05, 0.05), math.random(-0.05, 0.05), math.random(-0.05, 0.05)))
wait(0.03)
end
end
end)
end
Library.Things:FindFirstChild("Lootbags").ChildAdded:Connect(function(child)
wait()
if FarmUtilities_CollectDrops and child then
Library.Network.Fire("Collect Lootbag", child.Name, HumanoidRootPart.Position + Vector3.new(math.random(-0.05, 0.05), math.random(-0.05, 0.05), math.random(-0.05, 0.05)))
end
end)
Library.Things:FindFirstChild("Orbs").ChildAdded:Connect(function(child)
task.wait()
if FarmUtilities_CollectDrops and child then
table.insert(FarmUtilities_CurrentOrbs, child.name)
end
end)
autoFarmTab:CreateToggle({
Name = "Fast Pets",
SectionParent = farmUtilities,
CurrentValue = false,
Flag = "FarmUtilities_FastPets",
Callback = function(Value)
fastPets = Value
end
})
local instantFall = false
autoFarmTab:CreateToggle({
Name = "Instant Fall Coins",
SectionParent = farmUtilities,
CurrentValue = false,
Flag = "FarmUtilities_InstantFallCoins",
Callback = function(Value)
instantFall = Value
end
})
local WorldCoins = Library.Things:WaitForChild("Coins")
WorldCoins.ChildAdded:Connect(function(ch)
if instantFall then
ch:SetAttribute("HasLanded", true)
ch:SetAttribute("IsFalling", false)
local coin = ch:WaitForChild("Coin")
coin:SetAttribute("InstantLand", true)
end
end)
local areaToFarmSection = autoFarmTab:CreateSection("Areas to Farm", false, true)
for w, world in ipairs(AllGameWorlds) do
coroutine.wrap(function()
if world and world.name then
local containsSpawns = false
if world.spawns then
for i,v in pairs(world.spawns) do containsSpawns = true break end
end
if containsSpawns then
local worldDropdown = autoFarmTab:CreateDropdown({
Name = world.name,
MultiSelection = true,
CurrentOption = {},
Flag = "SelectedAreas_" .. world.name,
Icon = Library.Directory.Currency[world.mainCurrency].tinyImage,
Options = GetAllAreasInWorld(world),
SectionParent = areaToFarmSection,
Callback = function(Option)
end
})
worldDropdown:Lock("Coming soon!", true)
end
end
end)()
end
function GetCoinsInArea(area)
local coinsInArea = {}
for _, coin in pairs(WorldCoins:GetChildren()) do
if coin and coin:GetAttribute("Area") and coin:GetAttribute("Area") == area then
table.insert(coinsInArea, coin)
end
end
return coinsInArea
end
function GetCoinsInArea(area)
local coinsInArea = {}
for _, coin in pairs(WorldCoins:GetChildren()) do
if coin and coin:GetAttribute("Area") and coin:GetAttribute("Area") == area then
table.insert(coinsInArea, coin)
end
end
return coinsInArea
end
function SortCoinsByPriority(coins)
local sortedCoins = {}
CoinsTable = debug.getupvalue(getsenv(LocalPlayer.PlayerScripts.Scripts.Game.Coins).DestroyAllCoins, 1)
for _, coin in pairs(coins) do
local coinMesh = coin:FindFirstChild("Coin")
local mag = (HumanoidRootPart.Position - coinMesh.Position).magnitude
if CoinsTable[coin.Name] and mag <= math.max(math.min(farmMaxDistance, Library.Settings.CoinGrabDistance), 10) and Library.WorldCmds.HasArea(coin:GetAttribute("Area")) then
table.insert(sortedCoins, coin)
end
end
table.sort(sortedCoins, function(coinA, coinB)
local a = CoinsTable[coinA.Name]
local b = CoinsTable[coinB.Name]
local APriority = GetCoinLowestPriority(a, b)
local BPriority = GetCoinLowestPriority(b, a)
return APriority < BPriority
end)
return sortedCoins
end
function SortCoinsByPriorityFastMode(coins)
local sortedCoins = {}
for coinId, coin in pairs(coins) do
coin.coinId = coinId
local mag = (HumanoidRootPart.Position - coin.p).magnitude
if mag <= math.max(math.min(farmMaxDistance, Library.Settings.CoinGrabDistance), 10) and Library.WorldCmds.HasArea(coin.a) then
table.insert(sortedCoins, coin)
end
end
table.sort(sortedCoins, function(a, b)
local APriority = GetCoinLowestPriority(a, b)
local BPriority = GetCoinLowestPriority(b, a)
return APriority < BPriority
end)
return sortedCoins
end
function GetCoinLowestPriority(mainCoin, coinToCompare)
local coin = Library.Directory.Coins[mainCoin.n]
local coinCompare = Library.Directory.Coins[coinToCompare.n]
local aMagnitude = (HumanoidRootPart.Position - mainCoin.p).magnitude
local bMagnitude = (HumanoidRootPart.Position - coinToCompare.p).magnitude
local coinIsFruit = coin.breakSound == "fruit"
local coinIsDiamond = coin.currencyType == "Diamonds"
local coinIsEaster = coin.currencyType == "Easter Coins"
local coinHighestMultiplier = CalcMultiplier(mainCoin.b) > CalcMultiplier(coinToCompare.b)
local coinPriority = 9999999
To embed this project on your website, copy the following code and paste it into your website's HTML: