local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local RunService = game:GetService("RunService")
local Workspace = game:GetService("Workspace")
local UserInputService = game:GetService("UserInputService")
local VirtualInputManager = game:GetService("VirtualInputManager")
local GuiService = game:GetService("GuiService")

local LocalPlayer = Players.LocalPlayer
local PlayerGui = LocalPlayer:WaitForChild("PlayerGui")
local SystemGui = PlayerGui:WaitForChild("SystemGUI")
local EventHandler = SystemGui:WaitForChild("EventHandler")
local Inventory = SystemGui.MenuObject:WaitForChild("Inventory")
local Slots = Inventory:WaitForChild("Slots")
local BagValue = SystemGui:WaitForChild("Bag")
local ShopGui = SystemGui:WaitForChild("ShopGUI")
local RequestAttack = ReplicatedStorage:WaitForChild("RemoteObject"):WaitForChild("RequestAttack")
local SellRemote = EventHandler:WaitForChild("onDragToSell")
local SellCountRemote = ReplicatedStorage:WaitForChild("D8ClientFramework"):WaitForChild("RemoteObjects"):WaitForChild("RemoteEvent")

local TargetSelector = require(
	ReplicatedStorage
		.D8ClientFramework
		.Services
		.TargetSelectorService
		.Client_TargetSelectorService
)

local ItemList = require(ReplicatedStorage.D8ClientFramework.Services.ItemObjectService.Modules.ItemList)

local Character = LocalPlayer.Character or LocalPlayer.CharacterAdded:Wait()
LocalPlayer.CharacterAdded:Connect(function(NewCharacter)
	Character = NewCharacter
end)

local TargetEnabled = false
local ShortcutEnabled = false
local PickupEnabled = false
local ShortcutRunning = false
local CurrentTargetData
local CurrentTargetName = "None"
local PickupCooldown = 0

local SellSelection = {}
local AllItemNames = {}
local SellLoopEnabled = false
local SellCycleRunning = false
local LastSoldCount = 0
local SellStatusText = "Paused"

local SlotsPerBag = 36
local BagTimeout = 1.5
local SellCheckDelay = 0.2
local SlotLoopDelay = 0.03
local SellCycleDelay = 1
local MaxListRows = 220

local function Normalize(Value)
	return string.lower((Value or ""):gsub("^%s+", ""):gsub("%s+$", ""))
end

local function PressG()
	VirtualInputManager:SendKeyEvent(true, Enum.KeyCode.G, false, game)
	task.wait()
	VirtualInputManager:SendKeyEvent(false, Enum.KeyCode.G, false, game)
end

for Index, UiName in ipairs({ "AutomationStatusUI", "AutoSellListUI", "AutoSellBlacklistUI" }) do
	local Old = PlayerGui:FindFirstChild(UiName)
	if Old then
		Old:Destroy()
	end
end

local AutomationUi = Instance.new("ScreenGui")
AutomationUi.Name = "AutomationStatusUI"
AutomationUi.ResetOnSpawn = false
AutomationUi.Parent = PlayerGui

local AutoFrame = Instance.new("Frame")
AutoFrame.Size = UDim2.fromOffset(340, 140)
AutoFrame.Position = UDim2.new(0, 20, 0, 120)
AutoFrame.BackgroundColor3 = Color3.fromRGB(20, 20, 20)
AutoFrame.BackgroundTransparency = 0.2
AutoFrame.BorderSizePixel = 0
AutoFrame.Active = true
AutoFrame.Draggable = true
AutoFrame.Parent = AutomationUi

local AutoTitle = Instance.new("TextLabel")
AutoTitle.Size = UDim2.new(1, -10, 0, 24)
AutoTitle.Position = UDim2.fromOffset(5, 5)
AutoTitle.BackgroundTransparency = 1
AutoTitle.Font = Enum.Font.GothamBold
AutoTitle.TextSize = 14
AutoTitle.TextXAlignment = Enum.TextXAlignment.Left
AutoTitle.TextColor3 = Color3.fromRGB(255, 255, 255)
AutoTitle.Text = "Automation Status"
AutoTitle.Parent = AutoFrame

local TargetLabel = Instance.new("TextLabel")
TargetLabel.Size = UDim2.new(1, -10, 0, 24)
TargetLabel.Position = UDim2.fromOffset(5, 32)
TargetLabel.BackgroundTransparency = 1
TargetLabel.Font = Enum.Font.Gotham
TargetLabel.TextSize = 13
TargetLabel.TextXAlignment = Enum.TextXAlignment.Left
TargetLabel.Parent = AutoFrame

local ShortcutLabel = Instance.new("TextLabel")
ShortcutLabel.Size = UDim2.new(1, -10, 0, 24)
ShortcutLabel.Position = UDim2.fromOffset(5, 56)
ShortcutLabel.BackgroundTransparency = 1
ShortcutLabel.Font = Enum.Font.Gotham
ShortcutLabel.TextSize = 13
ShortcutLabel.TextXAlignment = Enum.TextXAlignment.Left
ShortcutLabel.Parent = AutoFrame

local PickupLabel = Instance.new("TextLabel")
PickupLabel.Size = UDim2.new(1, -10, 0, 24)
PickupLabel.Position = UDim2.fromOffset(5, 80)
PickupLabel.BackgroundTransparency = 1
PickupLabel.Font = Enum.Font.Gotham
PickupLabel.TextSize = 13
PickupLabel.TextXAlignment = Enum.TextXAlignment.Left
PickupLabel.Parent = AutoFrame

local AutoHint = Instance.new("TextLabel")
AutoHint.Size = UDim2.new(1, -10, 0, 16)
AutoHint.Position = UDim2.fromOffset(5, 112)
AutoHint.BackgroundTransparency = 1
AutoHint.Font = Enum.Font.Gotham
AutoHint.TextSize = 11
AutoHint.TextXAlignment = Enum.TextXAlignment.Left
AutoHint.TextColor3 = Color3.fromRGB(180, 180, 180)
AutoHint.Text = "Toggle: [E] Target  [T] Shortcuts  [Y] Pickup"
AutoHint.Parent = AutoFrame

local SellUi = Instance.new("ScreenGui")
SellUi.Name = "AutoSellListUI"
SellUi.ResetOnSpawn = false
SellUi.Parent = PlayerGui

local SellFrame = Instance.new("Frame")
SellFrame.Size = UDim2.fromOffset(250, 340)
SellFrame.Position = UDim2.new(0, 370, 0, 120)
SellFrame.BackgroundColor3 = Color3.fromRGB(20, 20, 20)
SellFrame.BorderSizePixel = 0
SellFrame.Active = true
SellFrame.Draggable = true
SellFrame.Parent = SellUi

local SellTitle = Instance.new("TextLabel")
SellTitle.Size = UDim2.new(1, -10, 0, 24)
SellTitle.Position = UDim2.fromOffset(5, 4)
SellTitle.BackgroundTransparency = 1
SellTitle.TextXAlignment = Enum.TextXAlignment.Left
SellTitle.Font = Enum.Font.GothamBold
SellTitle.TextSize = 13
SellTitle.TextColor3 = Color3.fromRGB(255, 255, 255)
SellTitle.Text = "Auto Sell List"
SellTitle.Parent = SellFrame

local SellStatusLabel = Instance.new("TextLabel")
SellStatusLabel.Size = UDim2.new(1, -10, 0, 18)
SellStatusLabel.Position = UDim2.fromOffset(5, 28)
SellStatusLabel.BackgroundTransparency = 1
SellStatusLabel.TextXAlignment = Enum.TextXAlignment.Left
SellStatusLabel.Font = Enum.Font.Gotham
SellStatusLabel.TextSize = 11
SellStatusLabel.TextColor3 = Color3.fromRGB(210, 210, 210)
SellStatusLabel.Parent = SellFrame

local SellToggleButton = Instance.new("TextButton")
SellToggleButton.Size = UDim2.fromOffset(95, 22)
SellToggleButton.Position = UDim2.fromOffset(5, 50)
SellToggleButton.Font = Enum.Font.GothamBold
SellToggleButton.TextSize = 11
SellToggleButton.TextColor3 = Color3.fromRGB(255, 255, 255)
SellToggleButton.BorderSizePixel = 0
SellToggleButton.Parent = SellFrame

local SellClearButton = Instance.new("TextButton")
SellClearButton.Size = UDim2.fromOffset(95, 22)
SellClearButton.Position = UDim2.fromOffset(105, 50)
SellClearButton.Font = Enum.Font.GothamBold
SellClearButton.TextSize = 11
SellClearButton.Text = "Clear Sell List"
SellClearButton.TextColor3 = Color3.fromRGB(255, 255, 255)
SellClearButton.BackgroundColor3 = Color3.fromRGB(110, 60, 60)
SellClearButton.BorderSizePixel = 0
SellClearButton.Parent = SellFrame

local SearchBox = Instance.new("TextBox")
SearchBox.Size = UDim2.new(1, -10, 0, 24)
SearchBox.Position = UDim2.fromOffset(5, 78)
SearchBox.Font = Enum.Font.Gotham
SearchBox.TextSize = 11
SearchBox.TextColor3 = Color3.fromRGB(255, 255, 255)
SearchBox.PlaceholderColor3 = Color3.fromRGB(180, 180, 180)
SearchBox.PlaceholderText = "Search item name..."
SearchBox.Text = ""
SearchBox.ClearTextOnFocus = false
SearchBox.BackgroundColor3 = Color3.fromRGB(35, 35, 35)
SearchBox.BorderSizePixel = 0
SearchBox.Parent = SellFrame

local SellInfoLabel = Instance.new("TextLabel")
SellInfoLabel.Size = UDim2.new(1, -10, 0, 16)
SellInfoLabel.Position = UDim2.fromOffset(5, 104)
SellInfoLabel.BackgroundTransparency = 1
SellInfoLabel.TextXAlignment = Enum.TextXAlignment.Left
SellInfoLabel.Font = Enum.Font.Gotham
SellInfoLabel.TextSize = 10
SellInfoLabel.TextColor3 = Color3.fromRGB(180, 180, 180)
SellInfoLabel.Parent = SellFrame

local ItemListFrame = Instance.new("ScrollingFrame")
ItemListFrame.Size = UDim2.new(1, -10, 1, -126)
ItemListFrame.Position = UDim2.fromOffset(5, 122)
ItemListFrame.BackgroundColor3 = Color3.fromRGB(28, 28, 28)
ItemListFrame.BorderSizePixel = 0
ItemListFrame.ScrollBarThickness = 6
ItemListFrame.CanvasSize = UDim2.fromOffset(0, 0)
ItemListFrame.Parent = SellFrame

local ItemListLayout = Instance.new("UIListLayout")
ItemListLayout.Padding = UDim.new(0, 2)
ItemListLayout.Parent = ItemListFrame

ItemListLayout:GetPropertyChangedSignal("AbsoluteContentSize"):Connect(function()
	ItemListFrame.CanvasSize = UDim2.fromOffset(0, ItemListLayout.AbsoluteContentSize.Y + 6)
end)

local function UpdateAutomationUi()
	TargetLabel.Text = ("Auto Target [E]: %s | Target: %s"):format(TargetEnabled and "ON" or "OFF", CurrentTargetName)
	TargetLabel.TextColor3 = TargetEnabled and Color3.fromRGB(85, 255, 85) or Color3.fromRGB(255, 85, 85)

	ShortcutLabel.Text = ("Shortcut Loop [T]: %s | %s"):format(ShortcutEnabled and "ON" or "OFF", ShortcutRunning and "Running" or "Idle")
	ShortcutLabel.TextColor3 = ShortcutEnabled and Color3.fromRGB(85, 200, 255) or Color3.fromRGB(255, 85, 85)

	PickupLabel.Text = ("Auto Pickup [Y]: %s"):format(PickupEnabled and "ON" or "OFF")
	PickupLabel.TextColor3 = PickupEnabled and Color3.fromRGB(255, 220, 85) or Color3.fromRGB(255, 85, 85)
end

local function GetSellSelectionCount()
	local Count = 0
	for Key in pairs(SellSelection) do
		Count += 1
	end
	return Count
end

local function UpdateSellUiStatus(Note)
	if Note then
		SellStatusText = Note
	end
	SellStatusLabel.Text = ("Auto Sell: %s | Sold last cycle: %d | %s"):format(SellLoopEnabled and "ON" or "OFF", LastSoldCount, SellStatusText)
	SellToggleButton.Text = SellLoopEnabled and "Pause Auto Sell" or "Resume Auto Sell"
	SellToggleButton.BackgroundColor3 = SellLoopEnabled and Color3.fromRGB(60, 120, 60) or Color3.fromRGB(130, 70, 70)
end

local function RenderSellList()
	for Index, Child in ipairs(ItemListFrame:GetChildren()) do
		if Child:IsA("TextButton") or Child:IsA("TextLabel") then
			Child:Destroy()
		end
	end

	local Query = Normalize(SearchBox.Text)
	local Matched = 0
	local Shown = 0

	for Index, ItemName in ipairs(AllItemNames) do
		local Key = Normalize(ItemName)
		if Query == "" or string.find(Key, Query, 1, true) then
			Matched += 1
			if Shown < MaxListRows then
				Shown += 1
				local Row = Instance.new("TextButton")
				Row.Size = UDim2.new(1, -6, 0, 22)
				Row.Position = UDim2.fromOffset(3, 0)
				Row.Font = Enum.Font.Gotham
				Row.TextSize = 12
				Row.TextXAlignment = Enum.TextXAlignment.Left
				Row.TextColor3 = Color3.fromRGB(255, 255, 255)
				Row.BorderSizePixel = 0
				Row.AutoButtonColor = false
				Row.Text = (SellSelection[Key] and "[x] " or "[ ] ") .. ItemName
				Row.BackgroundColor3 = SellSelection[Key] and Color3.fromRGB(40, 95, 40) or Color3.fromRGB(45, 45, 45)
				Row.Parent = ItemListFrame

				Row.MouseButton1Click:Connect(function()
					if SellSelection[Key] then
						SellSelection[Key] = nil
					else
						SellSelection[Key] = true
					end
					RenderSellList()
				end)
			end
		end
	end

	if Matched > MaxListRows then
		local More = Instance.new("TextLabel")
		More.Size = UDim2.new(1, -6, 0, 20)
		More.Position = UDim2.fromOffset(3, 0)
		More.BackgroundTransparency = 1
		More.TextXAlignment = Enum.TextXAlignment.Left
		More.Font = Enum.Font.Gotham
		More.TextSize = 11
		More.TextColor3 = Color3.fromRGB(180, 180, 180)
		More.Text = ("Refine search (%d results, showing %d)"):format(Matched, MaxListRows)
		More.Parent = ItemListFrame
	end

	SellInfoLabel.Text = ("Selected to sell: %d | Matches: %d | Source items: %d"):format(GetSellSelectionCount(), Matched, #AllItemNames)
end

do
	local Seen = {}
	local function AddName(Name)
		if type(Name) ~= "string" then return end
		local Raw = (Name:gsub("^%s+", ""):gsub("%s+$", ""))
		if Raw == "" then return end
		local Key = Normalize(Raw)
		if Seen[Key] then return end
		Seen[Key] = true
		table.insert(AllItemNames, Raw)
	end

	local Visited = {}
	local function Walk(Node)
		if type(Node) ~= "table" or Visited[Node] then return end
		Visited[Node] = true

		if type(Node.Name) == "string" then
			AddName(Node.Name)
		end

		for Key, Value in pairs(Node) do
			if type(Value) == "table" then
				if type(Value.Name) == "string" then
					AddName(Value.Name)
				elseif type(Key) == "string" and (Value.Class ~= nil or Value.Type ~= nil or Value.ID ~= nil or Value.LvReq ~= nil or Value.Grade ~= nil) then
					AddName(Key)
				end
				Walk(Value)
			elseif Key == "Name" and type(Value) == "string" then
				AddName(Value)
			end
		end
	end

	Walk(ItemList)
	table.sort(AllItemNames, function(A, B)
		return Normalize(A) < Normalize(B)
	end)
end

SellToggleButton.MouseButton1Click:Connect(function()
	SellLoopEnabled = not SellLoopEnabled
	UpdateSellUiStatus(SellLoopEnabled and "Running" or "Paused")
end)

SellClearButton.MouseButton1Click:Connect(function()
	table.clear(SellSelection)
	RenderSellList()
	UpdateSellUiStatus("Sell list cleared")
end)

SearchBox:GetPropertyChangedSignal("Text"):Connect(RenderSellList)

local function IsEnemyDead(Enemy, EnemyHumanoid, DataValue)
	if not Enemy or not Enemy.Parent then return true end
	if Enemy:GetAttribute("IsDead") then return true end
	if EnemyHumanoid and (EnemyHumanoid.Health <= 0 or EnemyHumanoid:GetState() == Enum.HumanoidStateType.Dead) then return true end
	if DataValue and DataValue:GetAttribute("IsDead") then return true end
	return false
end

local function ClearTarget()
	local HadTarget = CurrentTargetData ~= nil or CurrentTargetName ~= "None"
	CurrentTargetData = nil
	CurrentTargetName = "None"
	if HadTarget and TargetSelector.CancelTargetSelection then
		TargetSelector:CancelTargetSelection()
	end
	if HadTarget then
		UpdateAutomationUi()
	end
end

local function FindRenderFromData(DataValue)
	if not DataValue then return nil end
	local Cam = Workspace.CurrentCamera
	if not Cam then return nil end
	for Index, Enemy in ipairs(Cam:GetChildren()) do
		if Enemy:IsA("Model") then
			local Data = Enemy:FindFirstChild("Data")
			if Data and Data.Value == DataValue then
				return Enemy
			end
		end
	end
	return nil
end

local function RunShortcutCycle()
	for Index = 1, 15 do
		if not ShortcutEnabled then break end
		EventHandler.onShortCut:FireServer(tostring(Index))
		task.wait(0.1)
	end
end

local function UpdateAutoTarget()
	if not TargetEnabled then
		ClearTarget()
		return
	end

	if not Character or not Character.Parent then
		ClearTarget()
		return
	end

	local MyRoot = Character:FindFirstChild("HumanoidRootPart")
	local MyHumanoid = Character:FindFirstChildOfClass("Humanoid")
	if not MyRoot or not MyHumanoid or MyHumanoid.Health <= 0 then
		ClearTarget()
		return
	end

	if not TargetSelector.PlayerDataTarget or not TargetSelector.PlayerAttacking then
		return
	end

	if CurrentTargetData then
		local CurrentRender = FindRenderFromData(CurrentTargetData)
		if not CurrentRender then
			ClearTarget()
		else
			local CurrentHumanoid = CurrentRender:FindFirstChildOfClass("Humanoid")
			if CurrentRender:GetAttribute("NameHidden") or CurrentRender:FindFirstChild("NPC") then
				ClearTarget()
			elseif IsEnemyDead(CurrentRender, CurrentHumanoid, CurrentTargetData) then
				ClearTarget()
			end
		end
	end

	local Cam = Workspace.CurrentCamera
	if not Cam then return end

	local BestEnemy = nil
	local BestData = nil
	local BestDistance = 500

	for Index, Enemy in ipairs(Cam:GetChildren()) do
		if not Enemy:IsA("Model") then continue end
		if string.find(string.lower(Enemy.Name), "owner", 1, true) then continue end
		if Enemy:GetAttribute("NameHidden") then continue end
		if Enemy:FindFirstChild("NPC") then continue end

		local Data = Enemy:FindFirstChild("Data")
		local EnemyRoot = Enemy:FindFirstChild("HumanoidRootPart") or Enemy:FindFirstChild("Torso")
		local EnemyHumanoid = Enemy:FindFirstChildOfClass("Humanoid")
		local DataValue = Data and Data.Value or nil

		if not Data or not EnemyRoot or not EnemyHumanoid or not DataValue then continue end
		if IsEnemyDead(Enemy, EnemyHumanoid, DataValue) then continue end

		local Distance = (MyRoot.Position - EnemyRoot.Position).Magnitude
		if Distance < BestDistance then
			BestDistance = Distance
			BestEnemy = Enemy
			BestData = DataValue
		end
	end

	if not BestEnemy or not BestData then
		ClearTarget()
		return
	end

	if CurrentTargetData == BestData then
		return
	end

	CurrentTargetData = BestData
	CurrentTargetName = BestEnemy.Name
	UpdateAutomationUi()

	TargetSelector:ApplyTargetSelection(BestEnemy, "Monster", BestData)
	TargetSelector:ConfirmTargetSelection(BestEnemy, "Monster", BestData)
	RequestAttack:FireServer({ { BestData, 0 } })
end

local function UpdateAutoPickup(Delta)
	if not PickupEnabled then return end
	PickupCooldown += Delta
	if PickupCooldown < 1 then return end
	PickupCooldown = 0
	PressG()
	EventHandler.onLootAllClicked:FireServer()
end

local function ClickGuiButton(Button)
	local Inset = GuiService:GetGuiInset()
	local Center = Button.AbsolutePosition + (Button.AbsoluteSize / 2) + Inset
	VirtualInputManager:SendMouseMoveEvent(Center.X, Center.Y, game)
	RunService.Heartbeat:Wait()
	VirtualInputManager:SendMouseButtonEvent(Center.X, Center.Y, 0, true, game, 1)
	RunService.Heartbeat:Wait()
	VirtualInputManager:SendMouseButtonEvent(Center.X, Center.Y, 0, false, game, 1)
end

local function PressBagButton(Button)
	if not Button or not Button.Visible then return end
	pcall(function() firesignal(Button.Activated) end)
	pcall(function() firesignal(Button.MouseButton1Down) end)
	pcall(function() firesignal(Button.MouseButton1Click) end)
	pcall(function() firesignal(Button.MouseButton1Up) end)
	ClickGuiButton(Button)
	pcall(function() Button:Activate() end)
end

local function SwitchToBag(BagIndex)
	if BagValue.Value == BagIndex then return true end
	local BagButton = Inventory:FindFirstChild("Bag" .. tostring(BagIndex))
	if not BagButton then return false end
	PressBagButton(BagButton)
	local StartTime = tick()
	while tick() - StartTime < BagTimeout do
		if BagValue.Value == BagIndex then
			return true
		end
		RunService.Heartbeat:Wait()
	end
	return false
end

local function IsSelectedForSell(ObjectValue)
	local NameKey = Normalize(ObjectValue:GetAttribute("Name"))
	if NameKey == "" then return false end
	return SellSelection[NameKey] == true
end

local function TrySellSlot(SlotGui, BagIndex, SlotNumber)
	local ObjectValue = SlotGui:FindFirstChild("Object")
	if not ObjectValue then return false end
	if not IsSelectedForSell(ObjectValue) then return false end

	local BeforeName = ObjectValue:GetAttribute("Name")
	local BeforeCount = tonumber(ObjectValue:GetAttribute("Count")) or 1
	local GlobalSlot = ((BagIndex - 1) * SlotsPerBag) + SlotNumber

	local function FireSell(SlotIndex)
		SellRemote:FireServer(SlotIndex)

		local CountNow = tonumber(ObjectValue:GetAttribute("Count"))
		if CountNow and CountNow > 1 then
			SellCountRemote:FireServer(tostring(math.floor(CountNow)))
		end
	end

	FireSell(GlobalSlot)
	task.wait(SellCheckDelay)

	local AfterName = ObjectValue:GetAttribute("Name")
	local AfterCount = tonumber(ObjectValue:GetAttribute("Count")) or 0
	if AfterName ~= BeforeName or AfterCount < BeforeCount then
		return true
	end

	FireSell(SlotNumber)
	task.wait(SellCheckDelay)

	AfterName = ObjectValue:GetAttribute("Name")
	AfterCount = tonumber(ObjectValue:GetAttribute("Count")) or 0
	return AfterName ~= BeforeName or AfterCount < BeforeCount
end

local function SellCurrentBag(BagIndex)
	local SoldCount = 0
	for SlotNumber = 1, SlotsPerBag do
		if not SellLoopEnabled then
			break
		end
		local SlotGui = Slots:FindFirstChild(tostring(SlotNumber))
		if SlotGui and TrySellSlot(SlotGui, BagIndex, SlotNumber) then
			SoldCount += 1
		end
		task.wait(SlotLoopDelay)
	end
	return SoldCount
end

UserInputService.InputBegan:Connect(function(Input, GameProcessed)
	if GameProcessed then return end

	if Input.KeyCode == Enum.KeyCode.E then
		TargetEnabled = not TargetEnabled
		if not TargetEnabled then
			ClearTarget()
		end
		UpdateAutomationUi()
	elseif Input.KeyCode == Enum.KeyCode.T then
		ShortcutEnabled = not ShortcutEnabled
		UpdateAutomationUi()
	elseif Input.KeyCode == Enum.KeyCode.Y then
		PickupEnabled = not PickupEnabled
		if not PickupEnabled then
			PickupCooldown = 0
		end
		UpdateAutomationUi()
	end
end)

RunService.RenderStepped:Connect(function(Delta)
	UpdateAutoTarget()
	UpdateAutoPickup(Delta)

	if ShortcutEnabled and not ShortcutRunning then
		ShortcutRunning = true
		UpdateAutomationUi()
		task.spawn(function()
			RunShortcutCycle()
			ShortcutRunning = false
			UpdateAutomationUi()
		end)
	end
end)

task.spawn(function()
	while task.wait(SellCycleDelay) do
		if not SellLoopEnabled or SellCycleRunning then
			continue
		end

		if not ShopGui.Visible then
			LastSoldCount = 0
			UpdateSellUiStatus("Shop not open")
			continue
		end

		SellCycleRunning = true
		local TotalSold = 0

		for Bag = 1, 3 do
			if not SellLoopEnabled then
				break
			end
			if SwitchToBag(Bag) then
				TotalSold += SellCurrentBag(Bag)
			end
			task.wait(0.1)
		end

		if SellLoopEnabled then
			LastSoldCount = TotalSold
			UpdateSellUiStatus("Running")
		else
			UpdateSellUiStatus("Paused")
		end

		SellCycleRunning = false
	end
end)

UpdateAutomationUi()
RenderSellList()
UpdateSellUiStatus("Paused")
The Mystic Land 2 MMORPG [ Summons and AOE buff ] Auto Farm / Auto Skill
Mobile Friendly
843 views
7 months ago

Auto Farm / Auto Skill

WORKING
Free

Description

quick script for Mystic Land 2 with some basic auto stuff

auto sell works (need shop + bag open), also got auto skill, target and pickup so u can just chill while it farms

Features

  • Auto Sell
  • Auto Skill
  • Auto Target
  • Auto Pickup

Related Scripts