-- Loot Manager (WindUI) -- แยกแต่ละหมวดเป็นแท็บทางซ้าย -- ปุ่มกดได้เฉพาะเมื่อจำนวน > 0 local COUNT_DESCENDANTS = true local Y_OFFSET = 5 local Players = game:GetService("Players") local ReplicatedStorage = game:GetService("ReplicatedStorage") local LocalPlayer = Players.LocalPlayer local Version = "1.6.41" local WindUI = loadstring(game:HttpGet("https://github.com/Footagesus/WindUI/releases/download/" .. Version .. "/main.lua"))() local LootRS = ReplicatedStorage:WaitForChild("Loot", 5) local WorldLoot = workspace:FindFirstChild("Loot") ------------------------------------------------------ -- 🔹 Utility Functions ------------------------------------------------------ local function readCategories() local categories = {} if not LootRS then return categories end for _, cat in ipairs(LootRS:GetChildren()) do if cat:IsA("Folder") then local catName = cat.Name categories[catName] = {} for _, item in ipairs(cat:GetChildren()) do categories[catName][item.Name] = 0 end end end return categories end local function buildWorldCountMap() local map = {} if not WorldLoot then return map end local list = COUNT_DESCENDANTS and WorldLoot:GetDescendants() or WorldLoot:GetChildren() for _, inst in ipairs(list) do map[inst.Name] = (map[inst.Name] or 0) + 1 end return map end local function fillCounts(categories, worldMap) for _, items in pairs(categories) do for itemName in pairs(items) do items[itemName] = worldMap[itemName] or 0 end end end local function bringAllByName(itemName) if not WorldLoot then return end local char = LocalPlayer.Character or LocalPlayer.CharacterAdded:Wait() local hrp = char:WaitForChild("HumanoidRootPart") local targetCF = hrp.CFrame + Vector3.new(0, Y_OFFSET, 0) local list = COUNT_DESCENDANTS and WorldLoot:GetDescendants() or WorldLoot:GetChildren() for _, inst in ipairs(list) do if inst.Name == itemName then local obj = inst:FindFirstAncestorOfClass("Model") or inst if obj:IsA("Model") then if obj.PrimaryPart then obj:PivotTo(targetCF) else local p = obj:FindFirstChildWhichIsA("BasePart", true) if p then obj.PrimaryPart = p obj:PivotTo(targetCF) obj.PrimaryPart = nil end end else local bp = obj:IsA("BasePart") and obj or obj:FindFirstChildWhichIsA("BasePart", true) if bp then bp.CFrame = targetCF end end end end end ------------------------------------------------------ -- 🪟 WindUI Setup ------------------------------------------------------ local Window = WindUI:CreateWindow({ Title = "Loot Manager", Icon = "box", Theme = "Dark", Size = UDim2.fromOffset(620, 520), }) local ButtonRefs = {} -- [category][item] = btn ------------------------------------------------------ -- 🗂️ Build Tabs by Category ------------------------------------------------------ local function buildUI(categories) for catName, items in pairs(categories) do local Tab = Window:Tab({ Title = catName, Icon = "folder", }) ButtonRefs[catName] = {} -- เรียงของที่มีก่อน local available, unavailable = {}, {} for itemName, count in pairs(items) do if count > 0 then table.insert(available, {name = itemName, count = count}) else table.insert(unavailable, {name = itemName, count = count}) end end local ordered = {} for _, v in ipairs(available) do table.insert(ordered, v) end for _, v in ipairs(unavailable) do table.insert(ordered, v) end for _, data in ipairs(ordered) do local btn = Tab:Button({ Title = string.format("%s (%d)", data.name, data.count), Desc = "ดึงไอเท็มทั้งหมดชื่อนี้มาหาผู้เล่น", Callback = function() bringAllByName(data.name) end, }) if data.count <= 0 then btn:Lock() else btn:Unlock() end ButtonRefs[catName][data.name] = btn end end end ------------------------------------------------------ -- ♻️ Refresh Counts & Update Buttons ------------------------------------------------------ local function refreshUI(categories) for catName, items in pairs(categories) do for itemName, count in pairs(items) do local btn = ButtonRefs[catName] and ButtonRefs[catName][itemName] if btn then btn:SetTitle(string.format("%s (%d)", itemName, count)) if count > 0 then btn:Unlock() else btn:Lock() end end end end end ------------------------------------------------------ -- 🚀 Run ------------------------------------------------------ local Categories = readCategories() fillCounts(Categories, buildWorldCountMap()) buildUI(Categories) if WorldLoot then local function recalc() fillCounts(Categories, buildWorldCountMap()) refreshUI(Categories) end WorldLoot.ChildAdded:Connect(recalc) WorldLoot.ChildRemoved:Connect(recalc) if COUNT_DESCENDANTS then WorldLoot.DescendantAdded:Connect(recalc) WorldLoot.DescendantRemoving:Connect(recalc) end end