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")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
No comments yet. Be the first to comment!
1local Players = game:GetService("Players")
2local ReplicatedStorage = game:GetService("ReplicatedStorage")
3local RunService = game:GetService("RunService")
4local Workspace = game:GetService("Workspace")
5local UserInputService = game:GetService("UserInputService")
6local VirtualInputManager = game:GetService("VirtualInputManager")
7local GuiService = game:GetService("GuiService")
8
9local LocalPlayer = Players.LocalPlayer
10local PlayerGui = LocalPlayer:WaitForChild("PlayerGui")
11local SystemGui = PlayerGui:WaitForChild("SystemGUI")
12local EventHandler = SystemGui:WaitForChild("EventHandler")
13local Inventory = SystemGui.MenuObject:WaitForChild("Inventory")
14local Slots = Inventory:WaitForChild("Slots")
15local BagValue = SystemGui:WaitForChild("Bag")
16local ShopGui = SystemGui:WaitForChild("ShopGUI")
17local RequestAttack = ReplicatedStorage:WaitForChild("RemoteObject"):WaitForChild("RequestAttack")
18local SellRemote = EventHandler:WaitForChild("onDragToSell")
19local SellCountRemote = ReplicatedStorage:WaitForChild("D8ClientFramework"):WaitForChild("RemoteObjects"):WaitForChild("RemoteEvent")
20
21local TargetSelector = require(
22 ReplicatedStorage
23 .D8ClientFramework
24 .Services
25 .TargetSelectorService
26 .Client_TargetSelectorService
27)
28
29local ItemList = require(ReplicatedStorage.D8ClientFramework.Services.ItemObjectService.Modules.ItemList)
30
31local Character = LocalPlayer.Character or LocalPlayer.CharacterAdded:Wait()
32LocalPlayer.CharacterAdded:Connect(function(NewCharacter)
33 Character = NewCharacter
34end)
35
36local TargetEnabled = false
37local ShortcutEnabled = false
38local PickupEnabled = false
39local ShortcutRunning = false
40local CurrentTargetData
41local CurrentTargetName = "None"
42local PickupCooldown = 0
43
44local SellSelection = {}
45local AllItemNames = {}
46local SellLoopEnabled = false
47local SellCycleRunning = false
48local LastSoldCount = 0
49local SellStatusText = "Paused"
50
51local SlotsPerBag = 36
52local BagTimeout = 1.5
53local SellCheckDelay = 0.2
54local SlotLoopDelay = 0.03
55local SellCycleDelay = 1
56local MaxListRows = 220
57
58local function Normalize(Value)
59 return string.lower((Value or ""):gsub("^%s+", ""):gsub("%s+$", ""))
60end
61
62local function PressG()
63 VirtualInputManager:SendKeyEvent(true, Enum.KeyCode.G, false, game)
64 task.wait()
65 VirtualInputManager:SendKeyEvent(false, Enum.KeyCode.G, false, game)
66end
67
68for Index, UiName in ipairs({ "AutomationStatusUI", "AutoSellListUI", "AutoSellBlacklistUI" }) do
69 local Old = PlayerGui:FindFirstChild(UiName)
70 if Old then
71 Old:Destroy()
72 end
73end
74
75local AutomationUi = Instance.new("ScreenGui")
76AutomationUi.Name = "AutomationStatusUI"
77AutomationUi.ResetOnSpawn = false
78AutomationUi.Parent = PlayerGui
79
80local AutoFrame = Instance.new("Frame")
81AutoFrame.Size = UDim2.fromOffset(340, 140)
82AutoFrame.Position = UDim2.new(0, 20, 0, 120)
83AutoFrame.BackgroundColor3 = Color3.fromRGB(20, 20, 20)
84AutoFrame.BackgroundTransparency = 0.2
85AutoFrame.BorderSizePixel = 0
86AutoFrame.Active = true
87AutoFrame.Draggable = true
88AutoFrame.Parent = AutomationUi
89
90local AutoTitle = Instance.new("TextLabel")
91AutoTitle.Size = UDim2.new(1, -10, 0, 24)
92AutoTitle.Position = UDim2.fromOffset(5, 5)
93AutoTitle.BackgroundTransparency = 1
94AutoTitle.Font = Enum.Font.GothamBold
95AutoTitle.TextSize = 14
96AutoTitle.TextXAlignment = Enum.TextXAlignment.Left
97AutoTitle.TextColor3 = Color3.fromRGB(255, 255, 255)
98AutoTitle.Text = "Automation Status"
99AutoTitle.Parent = AutoFrame
100
101local TargetLabel = Instance.new("TextLabel")
102TargetLabel.Size = UDim2.new(1, -10, 0, 24)
103TargetLabel.Position = UDim2.fromOffset(5, 32)
104TargetLabel.BackgroundTransparency = 1
105TargetLabel.Font = Enum.Font.Gotham
106TargetLabel.TextSize = 13
107TargetLabel.TextXAlignment = Enum.TextXAlignment.Left
108TargetLabel.Parent = AutoFrame
109
110local ShortcutLabel = Instance.new("TextLabel")
111ShortcutLabel.Size = UDim2.new(1, -10, 0, 24)
112ShortcutLabel.Position = UDim2.fromOffset(5, 56)
113ShortcutLabel.BackgroundTransparency = 1
114ShortcutLabel.Font = Enum.Font.Gotham
115ShortcutLabel.TextSize = 13
116ShortcutLabel.TextXAlignment = Enum.TextXAlignment.Left
117ShortcutLabel.Parent = AutoFrame
118
119local PickupLabel = Instance.new("TextLabel")
120PickupLabel.Size = UDim2.new(1, -10, 0, 24)
121PickupLabel.Position = UDim2.fromOffset(5, 80)
122PickupLabel.BackgroundTransparency = 1
123PickupLabel.Font = Enum.Font.Gotham
124PickupLabel.TextSize = 13
125PickupLabel.TextXAlignment = Enum.TextXAlignment.Left
126PickupLabel.Parent = AutoFrame
127
128local AutoHint = Instance.new("TextLabel")
129AutoHint.Size = UDim2.new(1, -10, 0, 16)
130AutoHint.Position = UDim2.fromOffset(5, 112)
131AutoHint.BackgroundTransparency = 1
132AutoHint.Font = Enum.Font.Gotham
133AutoHint.TextSize = 11
134AutoHint.TextXAlignment = Enum.TextXAlignment.Left
135AutoHint.TextColor3 = Color3.fromRGB(180, 180, 180)
136AutoHint.Text = "Toggle: [E] Target [T] Shortcuts [Y] Pickup"
137AutoHint.Parent = AutoFrame
138
139local SellUi = Instance.new("ScreenGui")
140SellUi.Name = "AutoSellListUI"
141SellUi.ResetOnSpawn = false
142SellUi.Parent = PlayerGui
143
144local SellFrame = Instance.new("Frame")
145SellFrame.Size = UDim2.fromOffset(250, 340)
146SellFrame.Position = UDim2.new(0, 370, 0, 120)
147SellFrame.BackgroundColor3 = Color3.fromRGB(20, 20, 20)
148SellFrame.BorderSizePixel = 0
149SellFrame.Active = true
150SellFrame.Draggable = true
151SellFrame.Parent = SellUi
152
153local SellTitle = Instance.new("TextLabel")
154SellTitle.Size = UDim2.new(1, -10, 0, 24)
155SellTitle.Position = UDim2.fromOffset(5, 4)
156SellTitle.BackgroundTransparency = 1
157SellTitle.TextXAlignment = Enum.TextXAlignment.Left
158SellTitle.Font = Enum.Font.GothamBold
159SellTitle.TextSize = 13
160SellTitle.TextColor3 = Color3.fromRGB(255, 255, 255)
161SellTitle.Text = "Auto Sell List"
162SellTitle.Parent = SellFrame
163
164local SellStatusLabel = Instance.new("TextLabel")
165SellStatusLabel.Size = UDim2.new(1, -10, 0, 18)
166SellStatusLabel.Position = UDim2.fromOffset(5, 28)
167SellStatusLabel.BackgroundTransparency = 1
168SellStatusLabel.TextXAlignment = Enum.TextXAlignment.Left
169SellStatusLabel.Font = Enum.Font.Gotham
170SellStatusLabel.TextSize = 11
171SellStatusLabel.TextColor3 = Color3.fromRGB(210, 210, 210)
172SellStatusLabel.Parent = SellFrame
173
174local SellToggleButton = Instance.new("TextButton")
175SellToggleButton.Size = UDim2.fromOffset(95, 22)
176SellToggleButton.Position = UDim2.fromOffset(5, 50)
177SellToggleButton.Font = Enum.Font.GothamBold
178SellToggleButton.TextSize = 11
179SellToggleButton.TextColor3 = Color3.fromRGB(255, 255, 255)
180SellToggleButton.BorderSizePixel = 0
181SellToggleButton.Parent = SellFrame
182
183local SellClearButton = Instance.new("TextButton")
184SellClearButton.Size = UDim2.fromOffset(95, 22)
185SellClearButton.Position = UDim2.fromOffset(105, 50)
186SellClearButton.Font = Enum.Font.GothamBold
187SellClearButton.TextSize = 11
188SellClearButton.Text = "Clear Sell List"
189SellClearButton.TextColor3 = Color3.fromRGB(255, 255, 255)
190SellClearButton.BackgroundColor3 = Color3.fromRGB(110, 60, 60)
191SellClearButton.BorderSizePixel = 0
192SellClearButton.Parent = SellFrame
193
194local SearchBox = Instance.new("TextBox")
195SearchBox.Size = UDim2.new(1, -10, 0, 24)
196SearchBox.Position = UDim2.fromOffset(5, 78)
197SearchBox.Font = Enum.Font.Gotham
198SearchBox.TextSize = 11
199SearchBox.TextColor3 = Color3.fromRGB(255, 255, 255)
200SearchBox.PlaceholderColor3 = Color3.fromRGB(180, 180, 180)
201SearchBox.PlaceholderText = "Search item name..."
202SearchBox.Text = ""
203SearchBox.ClearTextOnFocus = false
204SearchBox.BackgroundColor3 = Color3.fromRGB(35, 35, 35)
205SearchBox.BorderSizePixel = 0
206SearchBox.Parent = SellFrame
207
208local SellInfoLabel = Instance.new("TextLabel")
209SellInfoLabel.Size = UDim2.new(1, -10, 0, 16)
210SellInfoLabel.Position = UDim2.fromOffset(5, 104)
211SellInfoLabel.BackgroundTransparency = 1
212SellInfoLabel.TextXAlignment = Enum.TextXAlignment.Left
213SellInfoLabel.Font = Enum.Font.Gotham
214SellInfoLabel.TextSize = 10
215SellInfoLabel.TextColor3 = Color3.fromRGB(180, 180, 180)
216SellInfoLabel.Parent = SellFrame
217
218local ItemListFrame = Instance.new("ScrollingFrame")
219ItemListFrame.Size = UDim2.new(1, -10, 1, -126)
220ItemListFrame.Position = UDim2.fromOffset(5, 122)
221ItemListFrame.BackgroundColor3 = Color3.fromRGB(28, 28, 28)
222ItemListFrame.BorderSizePixel = 0
223ItemListFrame.ScrollBarThickness = 6
224ItemListFrame.CanvasSize = UDim2.fromOffset(0, 0)
225ItemListFrame.Parent = SellFrame
226
227local ItemListLayout = Instance.new("UIListLayout")
228ItemListLayout.Padding = UDim.new(0, 2)
229ItemListLayout.Parent = ItemListFrame
230
231ItemListLayout:GetPropertyChangedSignal("AbsoluteContentSize"):Connect(function()
232 ItemListFrame.CanvasSize = UDim2.fromOffset(0, ItemListLayout.AbsoluteContentSize.Y + 6)
233end)
234
235local function UpdateAutomationUi()
236 TargetLabel.Text = ("Auto Target [E]: %s | Target: %s"):format(TargetEnabled and "ON" or "OFF", CurrentTargetName)
237 TargetLabel.TextColor3 = TargetEnabled and Color3.fromRGB(85, 255, 85) or Color3.fromRGB(255, 85, 85)
238
239 ShortcutLabel.Text = ("Shortcut Loop [T]: %s | %s"):format(ShortcutEnabled and "ON" or "OFF", ShortcutRunning and "Running" or "Idle")
240 ShortcutLabel.TextColor3 = ShortcutEnabled and Color3.fromRGB(85, 200, 255) or Color3.fromRGB(255, 85, 85)
241
242 PickupLabel.Text = ("Auto Pickup [Y]: %s"):format(PickupEnabled and "ON" or "OFF")
243 PickupLabel.TextColor3 = PickupEnabled and Color3.fromRGB(255, 220, 85) or Color3.fromRGB(255, 85, 85)
244end
245
246local function GetSellSelectionCount()
247 local Count = 0
248 for Key in pairs(SellSelection) do
249 Count += 1
250 end
251 return Count
252end
253
254local function UpdateSellUiStatus(Note)
255 if Note then
256 SellStatusText = Note
257 end
258 SellStatusLabel.Text = ("Auto Sell: %s | Sold last cycle: %d | %s"):format(SellLoopEnabled and "ON" or "OFF", LastSoldCount, SellStatusText)
259 SellToggleButton.Text = SellLoopEnabled and "Pause Auto Sell" or "Resume Auto Sell"
260 SellToggleButton.BackgroundColor3 = SellLoopEnabled and Color3.fromRGB(60, 120, 60) or Color3.fromRGB(130, 70, 70)
261end
262
263local function RenderSellList()
264 for Index, Child in ipairs(ItemListFrame:GetChildren()) do
265 if Child:IsA("TextButton") or Child:IsA("TextLabel") then
266 Child:Destroy()
267 end
268 end
269
270 local Query = Normalize(SearchBox.Text)
271 local Matched = 0
272 local Shown = 0
273
274 for Index, ItemName in ipairs(AllItemNames) do
275 local Key = Normalize(ItemName)
276 if Query == "" or string.find(Key, Query, 1, true) then
277 Matched += 1
278 if Shown < MaxListRows then
279 Shown += 1
280 local Row = Instance.new("TextButton")
281 Row.Size = UDim2.new(1, -6, 0, 22)
282 Row.Position = UDim2.fromOffset(3, 0)
283 Row.Font = Enum.Font.Gotham
284 Row.TextSize = 12
285 Row.TextXAlignment = Enum.TextXAlignment.Left
286 Row.TextColor3 = Color3.fromRGB(255, 255, 255)
287 Row.BorderSizePixel = 0
288 Row.AutoButtonColor = false
289 Row.Text = (SellSelection[Key] and "[x] " or "[ ] ") .. ItemName
290 Row.BackgroundColor3 = SellSelection[Key] and Color3.fromRGB(40, 95, 40) or Color3.fromRGB(45, 45, 45)
291 Row.Parent = ItemListFrame
292
293 Row.MouseButton1Click:Connect(function()
294 if SellSelection[Key] then
295 SellSelection[Key] = nil
296 else
297 SellSelection[Key] = true
298 end
299 RenderSellList()
300 end)
301 end
302 end
303 end
304
305 if Matched > MaxListRows then
306 local More = Instance.new("TextLabel")
307 More.Size = UDim2.new(1, -6, 0, 20)
308 More.Position = UDim2.fromOffset(3, 0)
309 More.BackgroundTransparency = 1
310 More.TextXAlignment = Enum.TextXAlignment.Left
311 More.Font = Enum.Font.Gotham
312 More.TextSize = 11
313 More.TextColor3 = Color3.fromRGB(180, 180, 180)
314 More.Text = ("Refine search (%d results, showing %d)"):format(Matched, MaxListRows)
315 More.Parent = ItemListFrame
316 end
317
318 SellInfoLabel.Text = ("Selected to sell: %d | Matches: %d | Source items: %d"):format(GetSellSelectionCount(), Matched, #AllItemNames)
319end
320
321do
322 local Seen = {}
323 local function AddName(Name)
324 if type(Name) ~= "string" then return end
325 local Raw = (Name:gsub("^%s+", ""):gsub("%s+$", ""))
326 if Raw == "" then return end
327 local Key = Normalize(Raw)
328 if Seen[Key] then return end
329 Seen[Key] = true
330 table.insert(AllItemNames, Raw)
331 end
332
333 local Visited = {}
334 local function Walk(Node)
335 if type(Node) ~= "table" or Visited[Node] then return end
336 Visited[Node] = true
337
338 if type(Node.Name) == "string" then
339 AddName(Node.Name)
340 end
341
342 for Key, Value in pairs(Node) do
343 if type(Value) == "table" then
344 if type(Value.Name) == "string" then
345 AddName(Value.Name)
346 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
347 AddName(Key)
348 end
349 Walk(Value)
350 elseif Key == "Name" and type(Value) == "string" then
351 AddName(Value)
352 end
353 end
354 end
355
356 Walk(ItemList)
357 table.sort(AllItemNames, function(A, B)
358 return Normalize(A) < Normalize(B)
359 end)
360end
361
362SellToggleButton.MouseButton1Click:Connect(function()
363 SellLoopEnabled = not SellLoopEnabled
364 UpdateSellUiStatus(SellLoopEnabled and "Running" or "Paused")
365end)
366
367SellClearButton.MouseButton1Click:Connect(function()
368 table.clear(SellSelection)
369 RenderSellList()
370 UpdateSellUiStatus("Sell list cleared")
371end)
372
373SearchBox:GetPropertyChangedSignal("Text"):Connect(RenderSellList)
374
375local function IsEnemyDead(Enemy, EnemyHumanoid, DataValue)
376 if not Enemy or not Enemy.Parent then return true end
377 if Enemy:GetAttribute("IsDead") then return true end
378 if EnemyHumanoid and (EnemyHumanoid.Health <= 0 or EnemyHumanoid:GetState() == Enum.HumanoidStateType.Dead) then return true end
379 if DataValue and DataValue:GetAttribute("IsDead") then return true end
380 return false
381end
382
383local function ClearTarget()
384 local HadTarget = CurrentTargetData ~= nil or CurrentTargetName ~= "None"
385 CurrentTargetData = nil
386 CurrentTargetName = "None"
387 if HadTarget and TargetSelector.CancelTargetSelection then
388 TargetSelector:CancelTargetSelection()
389 end
390 if HadTarget then
391 UpdateAutomationUi()
392 end
393end
394
395local function FindRenderFromData(DataValue)
396 if not DataValue then return nil end
397 local Cam = Workspace.CurrentCamera
398 if not Cam then return nil end
399 for Index, Enemy in ipairs(Cam:GetChildren()) do
400 if Enemy:IsA("Model") then
401 local Data = Enemy:FindFirstChild("Data")
402 if Data and Data.Value == DataValue then
403 return Enemy
404 end
405 end
406 end
407 return nil
408end
409
410local function RunShortcutCycle()
411 for Index = 1, 15 do
412 if not ShortcutEnabled then break end
413 EventHandler.onShortCut:FireServer(tostring(Index))
414 task.wait(0.1)
415 end
416end
417
418local function UpdateAutoTarget()
419 if not TargetEnabled then
420 ClearTarget()
421 return
422 end
423
424 if not Character or not Character.Parent then
425 ClearTarget()
426 return
427 end
428
429 local MyRoot = Character:FindFirstChild("HumanoidRootPart")
430 local MyHumanoid = Character:FindFirstChildOfClass("Humanoid")
431 if not MyRoot or not MyHumanoid or MyHumanoid.Health <= 0 then
432 ClearTarget()
433 return
434 end
435
436 if not TargetSelector.PlayerDataTarget or not TargetSelector.PlayerAttacking then
437 return
438 end
439
440 if CurrentTargetData then
441 local CurrentRender = FindRenderFromData(CurrentTargetData)
442 if not CurrentRender then
443 ClearTarget()
444 else
445 local CurrentHumanoid = CurrentRender:FindFirstChildOfClass("Humanoid")
446 if CurrentRender:GetAttribute("NameHidden") or CurrentRender:FindFirstChild("NPC") then
447 ClearTarget()
448 elseif IsEnemyDead(CurrentRender, CurrentHumanoid, CurrentTargetData) then
449 ClearTarget()
450 end
451 end
452 end
453
454 local Cam = Workspace.CurrentCamera
455 if not Cam then return end
456
457 local BestEnemy = nil
458 local BestData = nil
459 local BestDistance = 500
460
461 for Index, Enemy in ipairs(Cam:GetChildren()) do
462 if not Enemy:IsA("Model") then continue end
463 if string.find(string.lower(Enemy.Name), "owner", 1, true) then continue end
464 if Enemy:GetAttribute("NameHidden") then continue end
465 if Enemy:FindFirstChild("NPC") then continue end
466
467 local Data = Enemy:FindFirstChild("Data")
468 local EnemyRoot = Enemy:FindFirstChild("HumanoidRootPart") or Enemy:FindFirstChild("Torso")
469 local EnemyHumanoid = Enemy:FindFirstChildOfClass("Humanoid")
470 local DataValue = Data and Data.Value or nil
471
472 if not Data or not EnemyRoot or not EnemyHumanoid or not DataValue then continue end
473 if IsEnemyDead(Enemy, EnemyHumanoid, DataValue) then continue end
474
475 local Distance = (MyRoot.Position - EnemyRoot.Position).Magnitude
476 if Distance < BestDistance then
477 BestDistance = Distance
478 BestEnemy = Enemy
479 BestData = DataValue
480 end
481 end
482
483 if not BestEnemy or not BestData then
484 ClearTarget()
485 return
486 end
487
488 if CurrentTargetData == BestData then
489 return
490 end
491
492 CurrentTargetData = BestData
493 CurrentTargetName = BestEnemy.Name
494 UpdateAutomationUi()
495
496 TargetSelector:ApplyTargetSelection(BestEnemy, "Monster", BestData)
497 TargetSelector:ConfirmTargetSelection(BestEnemy, "Monster", BestData)
498 RequestAttack:FireServer({ { BestData, 0 } })
499end
500
501local function UpdateAutoPickup(Delta)
502 if not PickupEnabled then return end
503 PickupCooldown += Delta
504 if PickupCooldown < 1 then return end
505 PickupCooldown = 0
506 PressG()
507 EventHandler.onLootAllClicked:FireServer()
508end
509
510local function ClickGuiButton(Button)
511 local Inset = GuiService:GetGuiInset()
512 local Center = Button.AbsolutePosition + (Button.AbsoluteSize / 2) + Inset
513 VirtualInputManager:SendMouseMoveEvent(Center.X, Center.Y, game)
514 RunService.Heartbeat:Wait()
515 VirtualInputManager:SendMouseButtonEvent(Center.X, Center.Y, 0, true, game, 1)
516 RunService.Heartbeat:Wait()
517 VirtualInputManager:SendMouseButtonEvent(Center.X, Center.Y, 0, false, game, 1)
518end
519
520local function PressBagButton(Button)
521 if not Button or not Button.Visible then return end
522 pcall(function() firesignal(Button.Activated) end)
523 pcall(function() firesignal(Button.MouseButton1Down) end)
524 pcall(function() firesignal(Button.MouseButton1Click) end)
525 pcall(function() firesignal(Button.MouseButton1Up) end)
526 ClickGuiButton(Button)
527 pcall(function() Button:Activate() end)
528end
529
530local function SwitchToBag(BagIndex)
531 if BagValue.Value == BagIndex then return true end
532 local BagButton = Inventory:FindFirstChild("Bag" .. tostring(BagIndex))
533 if not BagButton then return false end
534 PressBagButton(BagButton)
535 local StartTime = tick()
536 while tick() - StartTime < BagTimeout do
537 if BagValue.Value == BagIndex then
538 return true
539 end
540 RunService.Heartbeat:Wait()
541 end
542 return false
543end
544
545local function IsSelectedForSell(ObjectValue)
546 local NameKey = Normalize(ObjectValue:GetAttribute("Name"))
547 if NameKey == "" then return false end
548 return SellSelection[NameKey] == true
549end
550
551local function TrySellSlot(SlotGui, BagIndex, SlotNumber)
552 local ObjectValue = SlotGui:FindFirstChild("Object")
553 if not ObjectValue then return false end
554 if not IsSelectedForSell(ObjectValue) then return false end
555
556 local BeforeName = ObjectValue:GetAttribute("Name")
557 local BeforeCount = tonumber(ObjectValue:GetAttribute("Count")) or 1
558 local GlobalSlot = ((BagIndex - 1) * SlotsPerBag) + SlotNumber
559
560 local function FireSell(SlotIndex)
561 SellRemote:FireServer(SlotIndex)
562
563 local CountNow = tonumber(ObjectValue:GetAttribute("Count"))
564 if CountNow and CountNow > 1 then
565 SellCountRemote:FireServer(tostring(math.floor(CountNow)))
566 end
567 end
568
569 FireSell(GlobalSlot)
570 task.wait(SellCheckDelay)
571
572 local AfterName = ObjectValue:GetAttribute("Name")
573 local AfterCount = tonumber(ObjectValue:GetAttribute("Count")) or 0
574 if AfterName ~= BeforeName or AfterCount < BeforeCount then
575 return true
576 end
577
578 FireSell(SlotNumber)
579 task.wait(SellCheckDelay)
580
581 AfterName = ObjectValue:GetAttribute("Name")
582 AfterCount = tonumber(ObjectValue:GetAttribute("Count")) or 0
583 return AfterName ~= BeforeName or AfterCount < BeforeCount
584end
585
586local function SellCurrentBag(BagIndex)
587 local SoldCount = 0
588 for SlotNumber = 1, SlotsPerBag do
589 if not SellLoopEnabled then
590 break
591 end
592 local SlotGui = Slots:FindFirstChild(tostring(SlotNumber))
593 if SlotGui and TrySellSlot(SlotGui, BagIndex, SlotNumber) then
594 SoldCount += 1
595 end
596 task.wait(SlotLoopDelay)
597 end
598 return SoldCount
599end
600
601UserInputService.InputBegan:Connect(function(Input, GameProcessed)
602 if GameProcessed then return end
603
604 if Input.KeyCode == Enum.KeyCode.E then
605 TargetEnabled = not TargetEnabled
606 if not TargetEnabled then
607 ClearTarget()
608 end
609 UpdateAutomationUi()
610 elseif Input.KeyCode == Enum.KeyCode.T then
611 ShortcutEnabled = not ShortcutEnabled
612 UpdateAutomationUi()
613 elseif Input.KeyCode == Enum.KeyCode.Y then
614 PickupEnabled = not PickupEnabled
615 if not PickupEnabled then
616 PickupCooldown = 0
617 end
618 UpdateAutomationUi()
619 end
620end)
621
622RunService.RenderStepped:Connect(function(Delta)
623 UpdateAutoTarget()
624 UpdateAutoPickup(Delta)
625
626 if ShortcutEnabled and not ShortcutRunning then
627 ShortcutRunning = true
628 UpdateAutomationUi()
629 task.spawn(function()
630 RunShortcutCycle()
631 ShortcutRunning = false
632 UpdateAutomationUi()
633 end)
634 end
635end)
636
637task.spawn(function()
638 while task.wait(SellCycleDelay) do
639 if not SellLoopEnabled or SellCycleRunning then
640 continue
641 end
642
643 if not ShopGui.Visible then
644 LastSoldCount = 0
645 UpdateSellUiStatus("Shop not open")
646 continue
647 end
648
649 SellCycleRunning = true
650 local TotalSold = 0
651
652 for Bag = 1, 3 do
653 if not SellLoopEnabled then
654 break
655 end
656 if SwitchToBag(Bag) then
657 TotalSold += SellCurrentBag(Bag)
658 end
659 task.wait(0.1)
660 end
661
662 if SellLoopEnabled then
663 LastSoldCount = TotalSold
664 UpdateSellUiStatus("Running")
665 else
666 UpdateSellUiStatus("Paused")
667 end
668
669 SellCycleRunning = false
670 end
671end)
672
673UpdateAutomationUi()
674RenderSellList()
675UpdateSellUiStatus("Paused")