--[[ TAVERN TOWN INSPECTOR AIO Version: 0.5.1 UI: WindUI 1.6.66 Features: - Animal ESP labels: clean species name + price (Rabbit - 25g) - Per-species toggles, colors, hostile notes - Distance fix: uses a real body part, not the model pivot - Owner detection: UserId -> Guests.Tavern_ and your Plot (1-8) - Experimental tavern automation (OFF by default): * Serve drinks (tap -> customer) * Collect empty mugs * Wash mugs in the wash basin - Animal auto farm (OFF by default): hunt selected animals with a bow (hold M1 to draw, aimed with lead + arc), collect bodies, walk speed boost - Tavern tools: interactable census, structure dumps, distance debug - Auto refresh is ALWAYS ON - RightShift / RightControl window toggle (custom handler) - Single-instance guard (re-executing replaces the old copy) Target: Roblox Player ]] --================================================== -- INITIALIZATION --================================================== local VERSION = "0.5.1" local WINDUI_VERSION = "1.6.66" local startedAt = os.clock() local WindUI = nil local Window = nil local Container = nil local Connections = {} local Entries = {} -- [instance] = entry local CONTAINER_NAME = "TavernInspectorVisuals" local CONFIG = { Version = VERSION, WindUIVersion = WINDUI_VERSION, MaxLogs = 60, AutoRefresh = true, -- always on (no toggle exists for it) Notifications = true, } local Settings = { Labels = true, Highlights = false, MaxHighlights = 30, ShowDistance = true, ShowPrice = true, ShowNotes = true, ShowHealth = true, ScanInterval = 1.5, -- Automation ActionDelay = 0.6, WashBatch = 1, WalkTimeout = 8, AutoTeleport = false, -- Animal auto farm HuntRadius = 300, HuntReach = 8, HuntMinHealth = 40, HuntTimeout = 40, CollectBodies = true, CollectWindow = 6, SkipHostile = true, WeaponName = "", HideMenuWhileHunting = true, -- Speed boost while hunting HuntBoostSpeed = true, HuntWalkSpeed = 32, -- Bow (hold M1 to draw, release to shoot) BowMode = true, BowRange = 60, BowCharge = 1.0, BowCooldown = 1.2, BowSpeed = 200, BowArc = 100, AimOffsetY = 0, } local State = { Running = true, Logs = {}, TotalCreated = 0, TotalRemoved = 0, LastScan = "Never", LastScanClock = 0, ScanDirty = true, } --================================================== -- SINGLE INSTANCE GUARD --================================================== local ENV = (type(getgenv) == "function" and getgenv()) or _G local INSTANCE_KEY = "__TavernTownInspector" local function sweepOrphans() local parents = {} if type(gethui) == "function" then pcall(function() table.insert(parents, gethui()) end) end pcall(function() table.insert(parents, game:GetService("CoreGui")) end) pcall(function() local lp = game:GetService("Players").LocalPlayer local pg = lp and lp:FindFirstChild("PlayerGui") if pg then table.insert(parents, pg) end end) for _, parent in ipairs(parents) do pcall(function() while true do local found = parent:FindFirstChild(CONTAINER_NAME) if not found then break end found:Destroy() end end) end -- Visuals left behind by older versions (they parented into the game). pcall(function() for _, obj in ipairs(game:GetService("Workspace"):GetDescendants()) do if obj.Name == "TavernInspectorHighlight" or obj.Name == "TavernInspectorLabel" then pcall(function() obj:Destroy() end) end end end) end local previous = ENV[INSTANCE_KEY] if previous and type(previous.Unload) == "function" then pcall(previous.Unload) task.wait(0.2) -- let the old window finish closing end ENV[INSTANCE_KEY] = nil sweepOrphans() --================================================== -- LOGGING --================================================== local function log(message) print(("[Tavern Inspector][%s] %s"):format( os.date("%H:%M:%S"), tostring(message) )) end local function addLog(message) table.insert(State.Logs, { Time = os.date("%H:%M:%S"), Message = tostring(message), }) while #State.Logs > CONFIG.MaxLogs do table.remove(State.Logs, 1) end log(message) end --================================================== -- NOTIFICATIONS --================================================== local function notify(title, content, duration) if not WindUI then warn("[Tavern Inspector] WindUI unavailable.") return end local ok, err = pcall(function() WindUI:Notify({ Title = title, Content = content, Duration = duration or 3, }) end) if not ok then warn("[Tavern Inspector] Notification error: " .. tostring(err)) end end local function safeNotify(title, content, duration) if CONFIG.Notifications then notify(title, content, duration) end end --================================================== -- CONNECTION MANAGEMENT --================================================== local function trackConnection(connection) table.insert(Connections, connection) return connection end local function disconnectAll() for _, connection in ipairs(Connections) do pcall(function() connection:Disconnect() end) end table.clear(Connections) end --================================================== -- WINDUI LOADER --================================================== local function loadWindUI() if type(loadstring) ~= "function" then error("Executor does not expose loadstring.") end local sourceUrl = "https://github.com/Footagesus/WindUI/releases/download/" .. WINDUI_VERSION .. "/main.lua" local response = game:HttpGet(sourceUrl) if type(response) ~= "string" or #response < 1000 then error("Invalid WindUI download response.") end local chunk, compileError = loadstring(response) if not chunk then error("WindUI compilation failed: " .. tostring(compileError)) end local ok, result = pcall(chunk) if not ok then error("WindUI initialization failed: " .. tostring(result)) end if type(result) ~= "table" or type(result.CreateWindow) ~= "function" then error("WindUI CreateWindow API unavailable.") end return result end local loadOK, loadResult = pcall(loadWindUI) if not loadOK then warn("[Tavern Inspector] INITIALIZATION FAILED") warn(tostring(loadResult)) return end WindUI = loadResult log("WindUI " .. WINDUI_VERSION .. " loaded.") --================================================== -- SERVICES --================================================== local Players = game:GetService("Players") local Workspace = game:GetService("Workspace") local RunService = game:GetService("RunService") local UserInputService = game:GetService("UserInputService") local VirtualInputManager = nil pcall(function() VirtualInputManager = game:GetService("VirtualInputManager") end) local LocalPlayer = Players.LocalPlayer --================================================== -- VISUAL CONTAINER --================================================== local function createContainer() local folder = Instance.new("Folder") folder.Name = CONTAINER_NAME local parent = nil if type(gethui) == "function" then pcall(function() parent = gethui() end) end if not parent then pcall(function() parent = game:GetService("CoreGui") end) end local ok = parent ~= nil and pcall(function() folder.Parent = parent end) if not ok or not folder.Parent then folder.Parent = LocalPlayer:WaitForChild("PlayerGui") end return folder end Container = createContainer() --================================================== -- SPECIES DATA --================================================== -- Order here = order of the toggles in the UI. local SPECIES_LIST = { { Name = "Rabbit", Price = "25g", Color = Color3.fromRGB(245, 245, 245), }, { Name = "Raccoon", Price = "50g", Color = Color3.fromRGB(160, 160, 185), }, { Name = "Fox", Price = "75g", Color = Color3.fromRGB(255, 140, 40), }, { Name = "Stag", Price = "150g", Color = Color3.fromRGB(205, 133, 63), }, { Name = "Bear", Price = "25 gems", Note = "hostile, 4 hits", Color = Color3.fromRGB(255, 70, 70), }, { Name = "Doe", Price = "125g", Color = Color3.fromRGB(255, 190, 150), }, { Name = "Wolf", Price = "5 gems", Note = "hostile, 2 hits", Color = Color3.fromRGB(120, 170, 255), }, { Name = "Boar", Price = "100g", Color = Color3.fromRGB(190, 90, 60), }, } local UNKNOWN_COLOR = Color3.fromRGB(220, 220, 220) local SPECIES_BY_LOWER = {} for _, species in ipairs(SPECIES_LIST) do SPECIES_BY_LOWER[species.Name:lower()] = species end local WildState = { Enabled = true, MaxDistance = 2000, Selected = {}, -- [canonical species name] = true / false } for _, species in ipairs(SPECIES_LIST) do WildState.Selected[species.Name] = true end --================================================== -- GENERAL HELPERS --================================================== local function findFolder(name) return Workspace:FindFirstChild(name) end -- Case-insensitive direct-child lookup. local function findChildCI(parent, name) if not parent then return nil end local exact = parent:FindFirstChild(name) if exact then return exact end local lowered = name:lower() for _, child in ipairs(parent:GetChildren()) do if child.Name:lower() == lowered then return child end end return nil end -- Turns "Rabbit256", "Rabbit_146", "Rabbit-7", "Rabbit 12" or "Rabbit (3)" -- into just "Rabbit". Falls back to the original name if nothing is left. local function cleanName(name) local original = tostring(name) local cleaned = original cleaned = cleaned:gsub("%s*%(%d+%)$", "") cleaned = cleaned:gsub("[%s_%-]*%d+$", "") cleaned = cleaned:gsub("[%s_%-]+$", "") if cleaned == "" then return original end return cleaned end -- Returns the species info (or nil) and the display name. local function identify(name) local cleaned = cleanName(name) local info = SPECIES_BY_LOWER[cleaned:lower()] if info then return info, info.Name end return nil, cleaned end local function isVisible(info, displayName) if info then return WildState.Selected[info.Name] == true end -- Unknown species are always shown. return true end -- Only the top-most Models / BaseParts under root -- (parts or sub-models inside an animal are not listed separately). local function getTopLevel(root) local results = {} if not root then return results end for _, descendant in ipairs(root:GetDescendants()) do if descendant:IsA("Model") or descendant:IsA("BasePart") then local nested = false local parent = descendant.Parent while parent and parent ~= root do if parent:IsA("Model") or parent:IsA("BasePart") then nested = true break end parent = parent.Parent end if not nested then table.insert(results, descendant) end end end return results end -- Real center of an instance based on its parts (NOT the model pivot, -- which can be stale on models that move without a PrimaryPart). local function centerOf(inst) if not inst then return nil end if inst:IsA("BasePart") then return inst.Position end if inst:IsA("Model") then local ok, cf = pcall(function() return inst:GetBoundingBox() end) if ok and cf then return cf.Position end end local sum = Vector3.new(0, 0, 0) local count = 0 for _, descendant in ipairs(inst:GetDescendants()) do if descendant:IsA("BasePart") then sum += descendant.Position count += 1 if count >= 200 then break end end end if count > 0 then return sum / count end return nil end local ANCHOR_NAMES = { "Torso", "UpperTorso", "LowerTorso", "Body", "Head", } -- The part that represents where an object REALLY is. -- Used for labels AND for distance. local function getAnchorPart(obj) if obj:IsA("BasePart") then return obj end if obj:IsA("Model") then local root = obj:FindFirstChild("HumanoidRootPart") or obj:FindFirstChild("RootPart") if root and root:IsA("BasePart") then return root end if obj.PrimaryPart then return obj.PrimaryPart end for _, name in ipairs(ANCHOR_NAMES) do local part = obj:FindFirstChild(name) if part and part:IsA("BasePart") then return part end end for _, descendant in ipairs(obj:GetDescendants()) do if descendant:IsA("BasePart") then return descendant end end end return nil end local function getPosition(obj) local part = getAnchorPart(obj) if part then return part.Position end return centerOf(obj) end local function getOrigin() local character = LocalPlayer and LocalPlayer.Character local root = character and character:FindFirstChild("HumanoidRootPart") if root then return root.Position end local camera = Workspace.CurrentCamera if camera then return camera.CFrame.Position end return Vector3.new(0, 0, 0) end local function countParts(obj) local count = 0 for _, descendant in ipairs(obj:GetDescendants()) do if descendant:IsA("BasePart") then count += 1 end end return count end --================================================== -- OWNER / TAVERN / PLOT DETECTION --================================================== local Owner = { UserId = LocalPlayer.UserId, TavernName = "Tavern_" .. tostring(LocalPlayer.UserId), Tavern = nil, Plot = nil, PlotName = nil, PlotReason = "not detected", PlotScores = {}, } local InfoParagraph = nil local function matchesPlayer(value) if value == nil then return false end local kind = typeof(value) if kind == "number" then return value == LocalPlayer.UserId end if kind == "string" then local lowered = value:lower() return lowered == tostring(LocalPlayer.UserId) or lowered == LocalPlayer.Name:lower() or lowered == LocalPlayer.DisplayName:lower() end if kind == "Instance" then return value == LocalPlayer end return false end local function textContainsPlayer(text) if type(text) ~= "string" or text == "" then return false end local lowered = text:lower() local name = LocalPlayer.Name:lower() local display = LocalPlayer.DisplayName:lower() if #name >= 3 and lowered:find(name, 1, true) then return true end if #display >= 3 and lowered:find(display, 1, true) then return true end return false end local function detectTavern() local guests = findChildCI(Workspace, "Guests") if not guests then Owner.Tavern = nil return nil end local tavern = findChildCI(guests, Owner.TavernName) if not tavern then local suffix = tostring(Owner.UserId) for _, child in ipairs(guests:GetChildren()) do if child.Name:sub(-#suffix) == suffix then tavern = child break end end end Owner.Tavern = tavern return tavern end local function listPlots() local plotsFolder = findChildCI(Workspace, "Plots") local plots = {} if plotsFolder then for _, child in ipairs(plotsFolder:GetChildren()) do if child.Name:lower():match("^plot") then table.insert(plots, child) end end table.sort(plots, function(a, b) return a.Name < b.Name end) end return plots, plotsFolder end -- Returns a score (0 = no ownership signal) and the reason. local function scorePlot(plot) local best, reason = 0, nil local function consider(score, why) if score > best then best, reason = score, why end end for key, value in pairs(plot:GetAttributes()) do if matchesPlayer(value) then consider(3, "plot attribute " .. tostring(key)) end end for _, descendant in ipairs(plot:GetDescendants()) do if descendant:IsA("ValueBase") then local ok, value = pcall(function() return descendant.Value end) if ok and matchesPlayer(value) then consider(3, "value object " .. descendant.Name) end elseif descendant:IsA("ProximityPrompt") then if textContainsPlayer(descendant.ObjectText) or textContainsPlayer(descendant.ActionText) then consider(2, "owner sign text") end end local lowered = descendant.Name:lower() if lowered:find("owner", 1, true) or lowered:find("sign", 1, true) then for key, value in pairs(descendant:GetAttributes()) do if matchesPlayer(value) then consider(3, descendant.Name .. " attribute " .. tostring(key)) end end end end return best, reason end local function detectPlot() local plots = listPlots() table.clear(Owner.PlotScores) if #plots == 0 then Owner.Plot = nil Owner.PlotName = nil Owner.PlotReason = "Workspace.Plots not found" return nil end local bestPlot, bestScore, bestReason = nil, 0, nil for _, plot in ipairs(plots) do local score, reason = scorePlot(plot) Owner.PlotScores[plot.Name] = { Score = score, Reason = reason } if score > bestScore then bestPlot, bestScore, bestReason = plot, score, reason end end -- Fallback: the plot closest to your tavern model. if not bestPlot and Owner.Tavern then local tavernPos = centerOf(Owner.Tavern) if tavernPos then local nearestDist = math.huge for _, plot in ipairs(plots) do local pos = centerOf(plot) if pos then local dist = (pos - tavernPos).Magnitude if dist < nearestDist then bestPlot, nearestDist = plot, dist end end end if bestPlot then bestReason = "nearest to tavern" end end end Owner.Plot = bestPlot Owner.PlotName = bestPlot and bestPlot.Name or nil Owner.PlotReason = bestReason or "no ownership signal found" return bestPlot end local function ownerInfoText() local tavernText = Owner.Tavern and Owner.Tavern.Name or (Owner.TavernName .. " (not found)") local plotText = "not detected" if Owner.Plot then plotText = Owner.Plot.Name .. " (" .. tostring(Owner.PlotReason) .. ")" else plotText = "not detected (" .. tostring(Owner.PlotReason) .. ")" end return ("UserId: %s\nTavern: %s\nPlot: %s"):format( tostring(Owner.UserId), tavernText, plotText ) end local function updateOwnerInfo() if InfoParagraph then pcall(function() InfoParagraph:SetDesc(ownerInfoText()) end) end end local function printOwnerReport() print("\n========== OWNER / TAVERN / PLOT ==========") print("Player:", LocalPlayer.Name, "| Display:", LocalPlayer.DisplayName) print("UserId:", Owner.UserId) print("Expected tavern:", "Workspace.Guests." .. Owner.TavernName) print("Tavern found:", Owner.Tavern and Owner.Tavern:GetFullName() or "NO") print("Plot found:", Owner.Plot and Owner.Plot:GetFullName() or "NO") print("Plot reason:", Owner.PlotReason) print("\nPlot scores:") local names = {} for name in pairs(Owner.PlotScores) do table.insert(names, name) end table.sort(names) if #names == 0 then print(" (no plots scanned)") end for _, name in ipairs(names) do local data = Owner.PlotScores[name] print(" " .. name, "score:", data.Score, data.Reason or "") end print("===========================================\n") end --================================================== -- INTERACTABLES (prompts / click detectors) --================================================== -- Role keywords. Matching is by whole words (camelCase is split), -- so "Tap1" matches "tap" but "Tapestry" does not. -- Adjust these once the Tavern Scan shows the real names. local ROLE_PATTERNS = { { Role = "Wash", Patterns = { "wash", "basin", "sink" } }, { Role = "Tap", Patterns = { "tap" } }, { Role = "Mug", Patterns = { "mug", "tankard", "cup", "stein" } }, { Role = "Serve", Patterns = { "serve", "deliver", "customer", "guest", "order" } }, } local TARGET_COOLDOWN = 1.5 local Auto = { Serve = false, Collect = false, Wash = false, Targets = {}, LastTargetScan = 0, LastUsed = {}, PendingMugs = 0, Stage = "tap", Stats = { Taps = 0, Served = 0, Collected = 0, Washed = 0, Failed = 0 }, } local function tokenize(text) local tokens = {} local spaced = tostring(text):gsub("(%l)(%u)", "%1 %2"):lower() for word in spaced:gmatch("%a+") do tokens[word] = true end return tokens end local function matchRole(text) local tokens = tokenize(text) for _, def in ipairs(ROLE_PATTERNS) do for _, pattern in ipairs(def.Patterns) do if tokens[pattern] or tokens[pattern .. "s"] then return def.Role end end end return nil end local function classify(inst, scopeRoot) local own = inst.Name if inst:IsA("ProximityPrompt") then own = own .. " " .. inst.ActionText .. " " .. inst.ObjectText end local role = matchRole(own) if role then return role end local parent = inst.Parent local depth = 0 while parent and parent ~= scopeRoot and depth < 4 do role = matchRole(parent.Name) if role then return role end parent = parent.Parent depth += 1 end return nil end local function targetPosition(inst) local parent = inst.Parent if not parent then return nil end if parent:IsA("Attachment") then return parent.WorldPosition end if parent:IsA("BasePart") then return parent.Position end return centerOf(parent) end local function refreshTargets() local targets = {} local seen = {} local scopes = {} if Owner.Tavern and Owner.Tavern.Parent then table.insert(scopes, Owner.Tavern) end if Owner.Plot and Owner.Plot.Parent then table.insert(scopes, Owner.Plot) end for _, scope in ipairs(scopes) do for _, descendant in ipairs(scope:GetDescendants()) do local isPrompt = descendant:IsA("ProximityPrompt") local isClick = descendant:IsA("ClickDetector") if (isPrompt or isClick) and not seen[descendant] then seen[descendant] = true table.insert(targets, { Instance = descendant, Kind = isPrompt and "Prompt" or "Click", Role = classify(descendant, scope), Scope = scope, }) end end end Auto.Targets = targets Auto.LastTargetScan = os.clock() return targets end local function pickTarget(role) local origin = getOrigin() local now = os.clock() local best, bestDist = nil, math.huge for _, target in ipairs(Auto.Targets) do if target.Role == role then local inst = target.Instance if inst.Parent and (target.Kind ~= "Prompt" or inst.Enabled) then local last = Auto.LastUsed[inst] if not last or now - last >= TARGET_COOLDOWN then local pos = targetPosition(inst) if pos then local dist = (pos - origin).Magnitude if dist < bestDist then best, bestDist = target, dist end end end end end end return best end local function autoActive() return State.Running and (Auto.Serve or Auto.Collect or Auto.Wash) end local function walkNear(pos, stopDistance, timeout, ignoreActiveCheck) local character = LocalPlayer.Character local humanoid = character and character:FindFirstChildOfClass("Humanoid") local root = character and character:FindFirstChild("HumanoidRootPart") if not humanoid or not root then return false end if Settings.AutoTeleport then local flat = Vector3.new(root.Position.X - pos.X, 0, root.Position.Z - pos.Z) local offset = flat.Magnitude > 0.1 and flat.Unit * 3 or Vector3.new(3, 0, 0) root.CFrame = CFrame.new(pos + offset + Vector3.new(0, 2, 0)) return true end local startClock = os.clock() local lastMove = 0 while State.Running and os.clock() - startClock < timeout do if not ignoreActiveCheck and not autoActive() then return false end if (root.Position - pos).Magnitude <= stopDistance then return true end if os.clock() - lastMove >= 1 then lastMove = os.clock() humanoid:MoveTo(pos) end task.wait(0.1) end return (root.Position - pos).Magnitude <= stopDistance + 2 end local function activate(target) local inst = target.Instance if target.Kind == "Prompt" then if type(fireproximityprompt) == "function" then local hold = inst.HoldDuration pcall(function() inst.HoldDuration = 0 end) local ok = pcall(fireproximityprompt, inst) pcall(function() inst.HoldDuration = hold end) return ok end return pcall(function() inst:InputHoldBegin() task.wait(math.max(inst.HoldDuration, 0) + 0.05) inst:InputHoldEnd() end) end if type(fireclickdetector) == "function" then return pcall(fireclickdetector, inst) end return false end local function interact(target, ignoreActiveCheck) local inst = target.Instance if not inst or not inst.Parent then return false end if target.Kind == "Prompt" and not inst.Enabled then return false end local pos = targetPosition(inst) if pos then local reach = math.max(2, inst.MaxActivationDistance * 0.7) if (getOrigin() - pos).Magnitude > reach then local arrived = walkNear( pos, reach * 0.8, Settings.WalkTimeout, ignoreActiveCheck ) if not arrived then Auto.LastUsed[inst] = os.clock() Auto.Stats.Failed += 1 return false end end end Auto.LastUsed[inst] = os.clock() local ok = activate(target) if not ok then Auto.Stats.Failed += 1 end return ok end local function automationStep() if os.clock() - Auto.LastTargetScan >= 2 then refreshTargets() end -- 1) Wash mugs. if Auto.Wash and Auto.PendingMugs > 0 then local shouldWash = Auto.PendingMugs >= Settings.WashBatch or not Auto.Collect or not pickTarget("Mug") if shouldWash then local target = pickTarget("Wash") if target and interact(target) then Auto.PendingMugs = math.max(0, Auto.PendingMugs - 1) Auto.Stats.Washed += 1 return end end end -- 2) Collect empty mugs. if Auto.Collect then local target = pickTarget("Mug") if target and interact(target) then Auto.PendingMugs += 1 Auto.Stats.Collected += 1 return end end -- 3) Serve drinks: alternate tap -> customer. if Auto.Serve then if Auto.Stage == "tap" then local target = pickTarget("Tap") if target and interact(target) then Auto.Stats.Taps += 1 end Auto.Stage = "serve" else local target = pickTarget("Serve") if target and interact(target) then Auto.Stats.Served += 1 end Auto.Stage = "tap" end end end --================================================== -- ANIMAL AUTO FARM (HUNT + COLLECT BODIES) --================================================== -- Words that mark a prompt as "pick up the body / carcass". -- Edit these after running "Body Scan" next to a dead animal. local BODY_WORDS = { "collect", "pickup", "harvest", "skin", "loot", "carcass", "corpse", "body", "meat", "hide", "carry", } -- Words used to auto-pick a weapon from your backpack. local WEAPON_WORDS = { "spear", "bow", "sword", "axe", "knife", "dagger", "club", "hammer", "pickaxe", "crossbow", "staff", "machete", } local ATTACK_DELAY = 0.35 -- Defined later in the file (TAVERN INSPECTION TOOLS). local describeForDump local Hunt = { Enabled = false, Current = nil, Blacklist = {}, LastWeaponWarn = 0, Track = {}, SavedCameraType = nil, OriginalSpeed = nil, Stats = { Hunted = 0, Collected = 0, Failed = 0, Shots = 0 }, } local function getCharacterParts() local character = LocalPlayer.Character local humanoid = character and character:FindFirstChildOfClass("Humanoid") local root = character and character:FindFirstChild("HumanoidRootPart") return character, humanoid, root end local function isAlive(obj) if not obj or not obj.Parent then return false end local humanoid = obj:IsA("Model") and obj:FindFirstChildOfClass("Humanoid") if humanoid then return humanoid.Health > 0 end local health = obj:GetAttribute("Health") if type(health) == "number" then return health > 0 end return true end -- Picks and equips a weapon. Returns the tool, or nil if none is usable. local function ensureWeapon(character, humanoid) local wanted = Settings.WeaponName:lower() if wanted == "" and Settings.BowMode then wanted = "bow" end local equipped = character:FindFirstChildOfClass("Tool") if equipped and (wanted == "" or equipped.Name:lower():find(wanted, 1, true)) then return equipped end local backpack = LocalPlayer:FindFirstChildOfClass("Backpack") local found = nil if backpack then for _, tool in ipairs(backpack:GetChildren()) do if tool:IsA("Tool") then local name = tool.Name:lower() if wanted ~= "" then if name:find(wanted, 1, true) then found = tool break end else for _, word in ipairs(WEAPON_WORDS) do if name:find(word, 1, true) then found = tool break end end if found then break end end end end end if found then pcall(function() humanoid:EquipTool(found) end) task.wait(0.15) return character:FindFirstChildOfClass("Tool") or found end if wanted ~= "" then return nil end return equipped end -- Returns the nearest huntable animal and its species info. -- Only known species whose toggle is ON are hunted. local function pickHuntTarget() local folder = findFolder("Wildlife") if not folder then return nil end local origin = getOrigin() local now = os.clock() local best, bestInfo, bestDist = nil, nil, math.huge for _, obj in ipairs(getTopLevel(folder)) do local expiry = Hunt.Blacklist[obj] if not expiry or now > expiry then local info = identify(obj.Name) local allowed = info ~= nil and WildState.Selected[info.Name] == true if allowed and Settings.SkipHostile and info.Note and info.Note:find("hostile", 1, true) then allowed = false end if allowed and isAlive(obj) then local pos = getPosition(obj) if pos then local dist = (pos - origin).Magnitude if dist <= Settings.HuntRadius and dist < bestDist then best, bestInfo, bestDist = obj, info, dist end end end end end return best, bestInfo end -- Press / release the left mouse button. Tries executor functions first, -- then VirtualInputManager, then Tool:Activate() / Deactivate(). local function mouseButton(down, tool) if down then if type(mouse1press) == "function" then return pcall(mouse1press) end else if type(mouse1release) == "function" then return pcall(mouse1release) end end if VirtualInputManager then local location = UserInputService:GetMouseLocation() local ok = pcall(function() VirtualInputManager:SendMouseButtonEvent(location.X, location.Y, 0, down, game, 0) end) if ok then return true end end if tool then return pcall(function() if down then tool:Activate() else tool:Deactivate() end end) end return false end local function moveCursor(x, y) if type(mousemoveabs) == "function" then pcall(mousemoveabs, x, y) return end if VirtualInputManager then pcall(function() VirtualInputManager:SendMouseMoveEvent(x, y, game) end) end end local function restoreCamera() local camera = Workspace.CurrentCamera if camera and Hunt.SavedCameraType then pcall(function() camera.CameraType = Hunt.SavedCameraType end) end Hunt.SavedCameraType = nil end -- Undo everything the hunt changes on your character / camera. local function restoreHuntState() restoreCamera() local _, humanoid = getCharacterParts() if Hunt.OriginalSpeed and humanoid then pcall(function() humanoid.WalkSpeed = Hunt.OriginalSpeed end) end Hunt.OriginalSpeed = nil end -- Measures how fast the animal is moving (for lead). local function estimateVelocity(obj, pos) local now = os.clock() local last = Hunt.Track[obj] local velocity = Vector3.new(0, 0, 0) if last then local dt = now - last.Time if dt > 0.01 and dt < 1 then local raw = (pos - last.Pos) / dt velocity = last.Vel:Lerp(raw, 0.5) end end Hunt.Track[obj] = { Pos = pos, Time = now, Vel = velocity } return velocity end -- Where to aim so the arrow meets a moving target: lead for its -- movement and raise the aim for the arrow's drop. local function predictAim(pos, velocity, origin) local dist = (pos - origin).Magnitude local flight = dist / math.max(Settings.BowSpeed, 1) local lead = velocity * flight local drop = 0.5 * Workspace.Gravity * flight * flight * (Settings.BowArc / 100) return pos + lead + Vector3.new(0, drop, 0) end local function aimAt(point) local camera = Workspace.CurrentCamera if not camera then return end camera.CFrame = CFrame.lookAt(camera.CFrame.Position, point) local viewport = camera.ViewportSize moveCursor(viewport.X / 2, viewport.Y / 2 + Settings.AimOffsetY) end -- Draw the bow (hold M1), keep the aim on the animal while drawing, -- then release. The game's own trajectory preview shows while held. local function bowShoot(obj, tool) local camera = Workspace.CurrentCamera local _, _, root = getCharacterParts() if not camera or not root then return false end local part = getAnchorPart(obj) if not part then return false end -- Take the camera for the shot only (restored right after). if camera.CameraType ~= Enum.CameraType.Scriptable then Hunt.SavedCameraType = camera.CameraType camera.CameraType = Enum.CameraType.Scriptable end local function updateAim() local current = getAnchorPart(obj) if not current then return false end local pos = current.Position local velocity = estimateVelocity(obj, pos) root.CFrame = CFrame.new(root.Position, Vector3.new(pos.X, root.Position.Y, pos.Z)) aimAt(predictAim(pos, velocity, root.Position)) return true end updateAim() task.wait(0.05) mouseButton(true, tool) local holdUntil = os.clock() + Settings.BowCharge while os.clock() < holdUntil and Hunt.Enabled and State.Running do if not isAlive(obj) or not updateAim() then break end task.wait(0.03) end -- One last aim update right before letting go. updateAim() mouseButton(false, tool) task.wait(0.05) restoreCamera() return true end -- Walks to the animal and attacks until it dies (or times out). -- Returns killed (bool) and the last position the animal was seen at. local function huntTarget(obj) local deadline = os.clock() + Settings.HuntTimeout local lastPos = getPosition(obj) local lastMove = 0 local lastAttack = 0 local killed = false Hunt.Track = {} while Hunt.Enabled and State.Running and os.clock() < deadline do local character, humanoid, root = getCharacterParts() if not character or not humanoid or not root or humanoid.Health <= 0 then break end if not isAlive(obj) then killed = true break end local part = getAnchorPart(obj) if not part then break end local pos = part.Position lastPos = pos local healthPercent = humanoid.MaxHealth > 0 and (humanoid.Health / humanoid.MaxHealth * 100) or 100 if healthPercent < Settings.HuntMinHealth then -- Too hurt: stand still and recover, don't burn the timer. humanoid:MoveTo(root.Position) deadline += 0.5 task.wait(0.5) else local dist = (root.Position - pos).Magnitude local reach = Settings.BowMode and Settings.BowRange or Settings.HuntReach if dist > reach then if os.clock() - lastMove >= 0.4 then lastMove = os.clock() humanoid:MoveTo(pos) end elseif Settings.BowMode then -- Stand still, draw the bow, aim with lead + arc, release. humanoid:MoveTo(root.Position) local tool = character:FindFirstChildOfClass("Tool") or ensureWeapon(character, humanoid) if tool then local ok, err = pcall(bowShoot, obj, tool) if not ok then mouseButton(false, tool) restoreCamera() addLog("Bow error: " .. tostring(err)) end Hunt.Stats.Shots += 1 -- Give the arrow time to land before shooting again. local waitUntil = os.clock() + Settings.BowCooldown while os.clock() < waitUntil and Hunt.Enabled and State.Running do if not isAlive(obj) then break end task.wait(0.1) end end else -- Melee: face the animal and swing. root.CFrame = CFrame.new( root.Position, Vector3.new(pos.X, root.Position.Y, pos.Z) ) if os.clock() - lastAttack >= ATTACK_DELAY then lastAttack = os.clock() local tool = character:FindFirstChildOfClass("Tool") or ensureWeapon(character, humanoid) if tool then pcall(function() tool:Activate() end) end end end task.wait(0.1) end end return killed, lastPos end -- Finds every prompt / click detector near a point. local function findNearbyInteractables(center, radius) local results = {} local seen = {} local ok, parts = pcall(function() return Workspace:GetPartBoundsInRadius(center, radius, OverlapParams.new()) end) if not ok then return results end local function consider(inst) if seen[inst] then return end if inst:IsA("ProximityPrompt") or inst:IsA("ClickDetector") then seen[inst] = true table.insert(results, { Instance = inst, Kind = inst:IsA("ProximityPrompt") and "Prompt" or "Click", Role = "Nearby", }) end end local function scanChildren(parent) for _, child in ipairs(parent:GetChildren()) do consider(child) if child:IsA("Attachment") then for _, sub in ipairs(child:GetChildren()) do consider(sub) end end end end local checkedModels = {} for index, part in ipairs(parts) do if index > 250 then break end scanChildren(part) local model = part.Parent if model and model:IsA("Model") and not checkedModels[model] then checkedModels[model] = true scanChildren(model) end end return results end local function interactableText(inst) local text = inst.Name if inst:IsA("ProximityPrompt") then text = text .. " " .. inst.ActionText .. " " .. inst.ObjectText end local parent = inst.Parent local depth = 0 while parent and parent ~= Workspace and depth < 3 do text = text .. " " .. parent.Name parent = parent.Parent depth += 1 end return text end local function findBodyTargets(center, radius) local targets = {} for _, target in ipairs(findNearbyInteractables(center, radius)) do local tokens = tokenize(interactableText(target.Instance)) local matched = false for _, word in ipairs(BODY_WORDS) do if tokens[word] or tokens[word .. "s"] then matched = true break end end if matched then target.Role = "Body" table.insert(targets, target) end end return targets end -- After a kill: look for "collect / skin / loot" style prompts near the body. local function collectBodies(center) local endClock = os.clock() + Settings.CollectWindow local fired = {} local gotAny = false while Hunt.Enabled and State.Running and os.clock() < endClock do local acted = false for _, target in ipairs(findBodyTargets(center, 25)) do if not fired[target.Instance] then fired[target.Instance] = true if interact(target, true) then Hunt.Stats.Collected += 1 gotAny = true acted = true end end end if not acted then task.wait(0.4) end end return gotAny end local function huntStep() local character, humanoid, root = getCharacterParts() if not character or not humanoid or not root or humanoid.Health <= 0 then task.wait(1) return end local target = pickHuntTarget() if not target then task.wait(1.5) return end if not ensureWeapon(character, humanoid) then if os.clock() - Hunt.LastWeaponWarn > 10 then Hunt.LastWeaponWarn = os.clock() addLog("Hunt: no weapon found. Equip one or type its name in the Hunt tab.") end task.wait(2) return end Hunt.Current = target local killed, lastPos = huntTarget(target) Hunt.Current = nil if killed then Hunt.Stats.Hunted += 1 if Settings.CollectBodies and lastPos then collectBodies(lastPos) end else -- Couldn't kill it in time: skip this one for a while. Hunt.Blacklist[target] = os.clock() + 30 Hunt.Stats.Failed += 1 end end local function printHuntStatus() print("\n========== HUNT STATUS ==========") print("Enabled:", Hunt.Enabled) print("Current target:", Hunt.Current and Hunt.Current.Name or "none") print("Bow mode:", Settings.BowMode, "Walk speed boost:", Settings.HuntBoostSpeed and Settings.HuntWalkSpeed or "off") print("Shots fired:", Hunt.Stats.Shots) print("Hunted:", Hunt.Stats.Hunted) print("Bodies collected:", Hunt.Stats.Collected) print("Failed / timed out:", Hunt.Stats.Failed) print("Skip hostile:", Settings.SkipHostile) print("Hunt radius:", Settings.HuntRadius, "Reach:", Settings.HuntReach) print("=================================\n") end -- Stand next to a dead animal and run this to see what you can interact with. local function bodyScan() local _, _, root = getCharacterParts() print("\n========== BODY SCAN (30 studs) ==========") if not root then print("No character.") print("==========================================\n") return end local list = findNearbyInteractables(root.Position, 30) print("Interactables nearby:", #list) for _, target in ipairs(list) do local inst = target.Instance local tokens = tokenize(interactableText(inst)) local match = false for _, word in ipairs(BODY_WORDS) do if tokens[word] or tokens[word .. "s"] then match = true end end print( match and "[BODY MATCH]" or "[other]", target.Kind, inst:GetFullName(), describeForDump(inst) ) end print("==========================================\n") addLog("Body scan: " .. #list .. " interactables nearby.") end local function printTools() print("\n========== YOUR TOOLS ==========") local character = LocalPlayer.Character local backpack = LocalPlayer:FindFirstChildOfClass("Backpack") local function dumpTool(tool, where) print(where, tool.Name, "[" .. tool.ClassName .. "]") for _, child in ipairs(tool:GetChildren()) do print(" " .. child.Name, "[" .. child.ClassName .. "]") end for key, value in pairs(tool:GetAttributes()) do print(" attr " .. tostring(key) .. " =", value) end end if character then for _, child in ipairs(character:GetChildren()) do if child:IsA("Tool") then dumpTool(child, "[equipped]") end end end if backpack then for _, child in ipairs(backpack:GetChildren()) do if child:IsA("Tool") then dumpTool(child, "[backpack]") end end end print("================================\n") end --================================================== -- SCANNING (AUTO REFRESH - ALWAYS ON) --================================================== local function removeHighlight(entry) if entry.Highlight then pcall(function() entry.Highlight:Destroy() end) entry.Highlight = nil end end local function ensureHighlight(entry) if entry.Highlight and entry.Highlight.Parent then return end local highlight = Instance.new("Highlight") highlight.Name = "TavernESPHighlight" highlight.Adornee = entry.Obj highlight.FillColor = entry.Color highlight.OutlineColor = entry.Color highlight.FillTransparency = 0.6 highlight.OutlineTransparency = 0 highlight.DepthMode = Enum.HighlightDepthMode.AlwaysOnTop highlight.Parent = Container entry.Highlight = highlight end local function removeEntry(obj) local entry = Entries[obj] if not entry then return end removeHighlight(entry) if entry.Gui then pcall(function() entry.Gui:Destroy() end) end Entries[obj] = nil State.TotalRemoved += 1 end local function clearAllEntries() for obj in pairs(Entries) do removeEntry(obj) end table.clear(Entries) end local function createEntry(obj, info, displayName) local part = getAnchorPart(obj) if not part then return end local height = 3 pcall(function() if obj:IsA("Model") then height = obj:GetExtentsSize().Y / 2 else height = obj.Size.Y / 2 end end) height = math.clamp(height + 1.5, 2, 30) local color = info and info.Color or UNKNOWN_COLOR local gui = Instance.new("BillboardGui") gui.Name = "TavernESPLabel" gui.Adornee = part gui.Size = UDim2.fromOffset(260, 20) gui.StudsOffset = Vector3.new(0, height, 0) gui.AlwaysOnTop = true gui.LightInfluence = 0 gui.Enabled = Settings.Labels gui.Parent = Container local label = Instance.new("TextLabel") label.Size = UDim2.fromScale(1, 1) label.BackgroundTransparency = 1 label.Text = displayName label.TextColor3 = color label.TextStrokeTransparency = 0.3 label.TextSize = 14 label.Font = Enum.Font.GothamBold label.Parent = gui local humanoid = nil if obj:IsA("Model") then humanoid = obj:FindFirstChildOfClass("Humanoid") end Entries[obj] = { Obj = obj, Info = info, Display = displayName, Part = part, Gui = gui, Label = label, Color = color, Humanoid = humanoid, Dist = 0, Text = "", } State.TotalCreated += 1 end local function buildText(entry) local text = entry.Display local info = entry.Info if info and info.Price and Settings.ShowPrice then text = text .. " - " .. info.Price end if info and info.Note and Settings.ShowNotes then text = text .. " (" .. info.Note .. ")" end if Settings.ShowDistance then text = text .. " [" .. math.floor(entry.Dist) .. "m]" end if Settings.ShowHealth then local health, maxHealth if entry.Humanoid and entry.Humanoid.Parent then health = entry.Humanoid.Health maxHealth = entry.Humanoid.MaxHealth else local attrHealth = entry.Obj:GetAttribute("Health") local attrMax = entry.Obj:GetAttribute("MaxHealth") if type(attrHealth) == "number" then health = attrHealth maxHealth = type(attrMax) == "number" and attrMax or nil end end if health then if maxHealth then text = text .. " " .. math.floor(health) .. "/" .. math.floor(maxHealth) else text = text .. " " .. math.floor(health) .. "hp" end end end return text end local function requestScan() State.ScanDirty = true end local missingWarned = false local function scanAll() if not WildState.Enabled then clearAllEntries() State.LastScan = os.date("%H:%M:%S") return end local folder = findFolder("Wildlife") if not folder then clearAllEntries() if not missingWarned then missingWarned = true addLog("Workspace.Wildlife not found.") end return end missingWarned = false local origin = getOrigin() local seen = {} for _, obj in ipairs(getTopLevel(folder)) do local info, displayName = identify(obj.Name) if isVisible(info, displayName) then local pos = getPosition(obj) if pos and (pos - origin).Magnitude <= WildState.MaxDistance then seen[obj] = true if not Entries[obj] then createEntry(obj, info, displayName) end end end end for obj in pairs(Entries) do if not seen[obj] then removeEntry(obj) end end State.LastScan = os.date("%H:%M:%S") end local function updateEntries() local origin = getOrigin() local list = {} for obj, entry in pairs(Entries) do if not WildState.Enabled or not obj:IsDescendantOf(Workspace) then removeEntry(obj) else if not entry.Part or not entry.Part:IsDescendantOf(Workspace) then entry.Part = getAnchorPart(obj) if entry.Part then entry.Gui.Adornee = entry.Part end end if not entry.Part then removeEntry(obj) else -- Distance comes from the real body part, not the model pivot. entry.Dist = (entry.Part.Position - origin).Magnitude entry.Gui.Enabled = Settings.Labels local text = buildText(entry) if text ~= entry.Text then entry.Text = text entry.Label.Text = text end table.insert(list, entry) end end end if Settings.Highlights then table.sort(list, function(a, b) return a.Dist < b.Dist end) for index, entry in ipairs(list) do if index <= Settings.MaxHighlights then ensureHighlight(entry) else removeHighlight(entry) end end else for _, entry in ipairs(list) do removeHighlight(entry) end end end --================================================== -- INSPECTION TOOLS --================================================== local function inspectFolder(folderName) local folder = findFolder(folderName) print("\n========== " .. folderName .. " INSPECTION ==========") if not folder then print("Folder not found in Workspace.") addLog(folderName .. " folder not found.") return end local descendants = folder:GetDescendants() local models, parts, folders = 0, 0, 0 for _, object in ipairs(descendants) do if object:IsA("Model") then models += 1 elseif object:IsA("BasePart") then parts += 1 elseif object:IsA("Folder") then folders += 1 end end print("Folder:", folder:GetFullName()) print("Direct children:", #folder:GetChildren()) print("Total descendants:", #descendants) print("Models:", models, "BaseParts:", parts, "Folders:", folders) print("\nDirect children:") for _, child in ipairs(folder:GetChildren()) do print(child.Name, "[" .. child.ClassName .. "]", "Children:", #child:GetChildren()) end print("==========================================\n") addLog(folderName .. " inspection completed.") end local function inspectObject(obj) if not obj then return end print("\n========== OBJECT STRUCTURE ==========") print("Name:", obj.Name) print("Clean name:", cleanName(obj.Name)) print("Class:", obj.ClassName) print("FullName:", obj:GetFullName()) local pos = getPosition(obj) print("Position:", pos and tostring(pos) or "Unknown") if obj:IsA("Model") then local anchor = getAnchorPart(obj) print("PrimaryPart:", obj.PrimaryPart and obj.PrimaryPart.Name or "None") print("Anchor part:", anchor and anchor.Name or "None") print("Direct children:", #obj:GetChildren()) print("Total descendants:", #obj:GetDescendants()) print("BaseParts:", countParts(obj)) local humanoid = obj:FindFirstChildOfClass("Humanoid") if humanoid then print("Humanoid:", humanoid.Health .. "/" .. humanoid.MaxHealth) else print("Humanoid: None") end end local attributes = {} pcall(function() attributes = obj:GetAttributes() end) print("\nAttributes:") local hasAttributes = false for key, value in pairs(attributes) do hasAttributes = true print(" " .. tostring(key) .. " =", value) end if not hasAttributes then print(" (none)") end local function printHierarchy(parent, depth) if depth > 8 then print(string.rep(" ", depth) .. "... depth limit") return end for _, child in ipairs(parent:GetChildren()) do print(string.rep(" ", depth) .. child.Name, "[" .. child.ClassName .. "]") printHierarchy(child, depth + 1) end end print("\nHierarchy:") printHierarchy(obj, 0) print("======================================\n") end local function inspectNearest() local folder = findFolder("Wildlife") if not folder then addLog("Wildlife folder not found.") return end local origin = getOrigin() local nearest, nearestDist = nil, math.huge for _, obj in ipairs(getTopLevel(folder)) do local pos = getPosition(obj) if pos then local dist = (pos - origin).Magnitude if dist < nearestDist then nearest, nearestDist = obj, dist end end end if not nearest then addLog("No animals found.") return end print(("Nearest animal: %s at %d studs"):format(nearest.Name, math.floor(nearestDist))) inspectObject(nearest) addLog("Inspected nearest animal: " .. nearest.Name) end -- Prints, for the 6 nearest animals, the distance by each method. -- If "pivot dist" disagrees with "anchor dist", the model pivot is stale. local function distanceDebug() local folder = findFolder("Wildlife") print("\n========== DISTANCE DEBUG ==========") local character = LocalPlayer.Character local root = character and character:FindFirstChild("HumanoidRootPart") local camera = Workspace.CurrentCamera print("Player root:", root and tostring(root.Position) or "NONE") print("Camera:", camera and tostring(camera.CFrame.Position) or "NONE") if not folder then print("Workspace.Wildlife not found.") print("====================================\n") return end local origin = getOrigin() local rows = {} for _, obj in ipairs(getTopLevel(folder)) do local anchor = getAnchorPart(obj) if anchor then table.insert(rows, { Obj = obj, Anchor = anchor, Dist = (anchor.Position - origin).Magnitude, }) end end table.sort(rows, function(a, b) return a.Dist < b.Dist end) for index = 1, math.min(6, #rows) do local row = rows[index] local obj = row.Obj local pivotDist = "n/a" if obj:IsA("Model") then local ok, cf = pcall(function() return obj:GetPivot() end) if ok then pivotDist = tostring(math.floor((cf.Position - origin).Magnitude)) end end local center = centerOf(obj) local bboxDist = center and tostring(math.floor((center - origin).Magnitude)) or "n/a" print( obj.Name, "| anchor:", row.Anchor.Name, math.floor(row.Dist), "| pivot dist:", pivotDist, "| bbox dist:", bboxDist, "| PrimaryPart:", obj:IsA("Model") and obj.PrimaryPart and obj.PrimaryPart.Name or "none" ) end print("====================================\n") addLog("Distance debug printed.") end local function speciesCensus() print("\n========== SPECIES CENSUS ==========") local folder = findFolder("Wildlife") if not folder then print("Workspace.Wildlife not found.") print("====================================\n") addLog("Wildlife folder not found.") return end local counts = {} local rawExamples = {} local total = 0 for _, obj in ipairs(getTopLevel(folder)) do local info, displayName = identify(obj.Name) counts[displayName] = (counts[displayName] or 0) + 1 rawExamples[displayName] = rawExamples[displayName] or obj.Name total += 1 end local names = {} for name in pairs(counts) do table.insert(names, name) end table.sort(names) print("Total animals:", total) for _, name in ipairs(names) do local known = SPECIES_BY_LOWER[name:lower()] ~= nil print( name, counts[name], "(e.g. " .. rawExamples[name] .. ")", known and "" or "<-- NEW (no price/color set)" ) end print("====================================\n") addLog("Species census completed.") end --================================================== -- TAVERN INSPECTION TOOLS --================================================== function describeForDump(inst) local extra = "" if inst:IsA("ProximityPrompt") then extra = (' Action="%s" Object="%s" Enabled=%s Range=%s'):format( inst.ActionText, inst.ObjectText, tostring(inst.Enabled), tostring(inst.MaxActivationDistance) ) elseif inst:IsA("ClickDetector") then extra = " (click, range " .. tostring(inst.MaxActivationDistance) .. ")" elseif inst:IsA("ValueBase") then local ok, value = pcall(function() return inst.Value end) if ok then extra = " = " .. tostring(value) end end local attrParts = {} local shown = 0 for key, value in pairs(inst:GetAttributes()) do shown += 1 if shown <= 5 then table.insert(attrParts, tostring(key) .. "=" .. tostring(value)) end end if shown > 0 then extra = extra .. " {" .. table.concat(attrParts, ", ") .. (shown > 5 and ", ..." or "") .. "}" end return extra end local function dumpTree(title, root, maxDepth, maxLines) print("\n========== " .. title .. " ==========") if not root then print("Not found.") print("=====================================\n") addLog(title .. ": not found.") return end print("Path:", root:GetFullName()) local lines = 0 local function walk(inst, depth) for _, child in ipairs(inst:GetChildren()) do if lines >= maxLines then return end lines += 1 print( string.rep(" ", depth) .. child.Name, "[" .. child.ClassName .. "]" .. describeForDump(child) ) if depth < maxDepth then walk(child, depth + 1) end end end walk(root, 0) if lines >= maxLines then print("... truncated at " .. maxLines .. " lines") end print("=====================================\n") addLog(title .. " dumped.") end local function findDescendantLike(roots, needle) local target = needle:lower() for _, root in ipairs(roots) do if root and root.Parent then for _, descendant in ipairs(root:GetDescendants()) do local flat = descendant.Name:lower():gsub("%s", "") if flat:find(target, 1, true) then return descendant end end end end return nil end local function tavernRoots() return { Owner.Tavern, Owner.Plot } end local function interactableCensus() refreshTargets() print("\n========== INTERACTABLE CENSUS ==========") if not Owner.Tavern and not Owner.Plot then print("No tavern or plot detected yet. Use 'Detect Tavern & Plot'.") print("=========================================\n") return end print("Tavern:", Owner.Tavern and Owner.Tavern:GetFullName() or "none") print("Plot:", Owner.Plot and Owner.Plot:GetFullName() or "none") print("Total interactables:", #Auto.Targets) local counts = {} for index, target in ipairs(Auto.Targets) do local role = target.Role or "(no role)" local inst = target.Instance counts[role] = (counts[role] or 0) + 1 if index <= 250 then print( ("[%s] %s | %s |%s"):format( role, target.Kind, inst:GetFullName(), describeForDump(inst) ) ) end end if #Auto.Targets > 250 then print("... " .. (#Auto.Targets - 250) .. " more not printed") end print("\nBy role:") for role, count in pairs(counts) do print(" " .. role .. ":", count) end print("=========================================\n") addLog("Interactable census completed: " .. #Auto.Targets) end local function printAutomationStatus() print("\n========== AUTOMATION STATUS ==========") print("Serve:", Auto.Serve, "Collect:", Auto.Collect, "Wash:", Auto.Wash) print("Pending mugs:", Auto.PendingMugs) print("Taps:", Auto.Stats.Taps, "Served:", Auto.Stats.Served) print("Collected:", Auto.Stats.Collected, "Washed:", Auto.Stats.Washed) print("Failed:", Auto.Stats.Failed) print("fireproximityprompt:", type(fireproximityprompt) == "function") print("fireclickdetector:", type(fireclickdetector) == "function") print("=======================================\n") end local function printLogs() print("\n========== TAVERN INSPECTOR LOGS ==========") if #State.Logs == 0 then print("No events recorded.") end for _, entry in ipairs(State.Logs) do print("[" .. entry.Time .. "] " .. entry.Message) end print("===========================================\n") end local function printReport() local counts = {} local total = 0 for _, entry in pairs(Entries) do counts[entry.Display] = (counts[entry.Display] or 0) + 1 total += 1 end print("\n========== INSPECTOR REPORT ==========") print("Version:", VERSION) print("WindUI:", WINDUI_VERSION) print("Player:", LocalPlayer and LocalPlayer.Name or "Unavailable") print("UserId:", Owner.UserId) print("Tavern:", Owner.Tavern and Owner.Tavern.Name or "not found") print("Plot:", Owner.Plot and Owner.Plot.Name or "not detected") print("PlaceId:", game.PlaceId) print("GameId:", game.GameId) print("ESP enabled:", WildState.Enabled, "Max distance:", WildState.MaxDistance) print("Active ESP objects:", total) for name, count in pairs(counts) do print(" " .. name .. ":", count) end print("Total created:", State.TotalCreated) print("Total removed:", State.TotalRemoved) print("Last scan:", State.LastScan) print("======================================\n") end --================================================== -- INITIAL OWNER DETECTION --================================================== pcall(detectTavern) pcall(detectPlot) addLog("Owner UserId: " .. tostring(Owner.UserId)) addLog("Tavern: " .. (Owner.Tavern and Owner.Tavern.Name or "not found yet")) addLog("Plot: " .. (Owner.Plot and (Owner.Plot.Name .. " (" .. tostring(Owner.PlotReason) .. ")") or "not detected yet")) --================================================== -- WINDOW --================================================== Window = WindUI:CreateWindow({ Title = "Tavern Town | Inspector AIO", Author = "Author: asuralangley - AIO v" .. VERSION, Icon = "paw-print", Theme = "Dark", Size = UDim2.fromOffset(680, 500), MinSize = Vector2.new(560, 400), Resizable = true, HideSearchBar = false, Folder = "TavernTownInspector", }) --================================================== -- CUSTOM TOGGLE KEYBIND -- (WindUI's built-in ToggleKey is intentionally not used, -- so only one handler ever toggles the window.) --================================================== local TOGGLE_KEYS = { [Enum.KeyCode.RightShift] = true, [Enum.KeyCode.RightControl] = true, } local windowOpen = true local lastToggle = 0 local function toggleWindow() if os.clock() - lastToggle < 0.15 then return end lastToggle = os.clock() local method = nil -- 1) WindUI's own toggle. if pcall(function() Window:Toggle() end) then method = "Window:Toggle()" end -- 2) Explicit Open / Close. if not method then local ok if windowOpen then ok = pcall(function() Window:Close() end) else ok = pcall(function() Window:Open() end) end if ok then method = windowOpen and "Window:Close()" or "Window:Open()" end end -- 3) Last resort: flip the main frame's visibility directly. if not method then if pcall(function() local main = Window.UIElements.Main main.Visible = not main.Visible end) then method = "UIElements.Main.Visible" end end if method then windowOpen = not windowOpen log("Window toggled via " .. method) else warn("[Tavern Inspector] Could not toggle the window (no usable method).") end end trackConnection(UserInputService.InputBegan:Connect(function(input) if input.UserInputType ~= Enum.UserInputType.Keyboard then return end if not TOGGLE_KEYS[input.KeyCode] then return end -- Don't toggle while typing in a text box (chat, etc.). if UserInputService:GetFocusedTextBox() then return end toggleWindow() end)) log(("Window methods: Toggle=%s Open=%s Close=%s"):format( tostring(type(Window.Toggle) == "function"), tostring(type(Window.Open) == "function"), tostring(type(Window.Close) == "function") )) pcall(function() Window:Tag({ Title = "v" .. VERSION, Color = "Success", }) end) local Dashboard = Window:Tab({ Title = "Dashboard", Icon = "layout-dashboard", }) local WildlifeTab = Window:Tab({ Title = "Wildlife", Icon = "paw-print", }) local TavernTab = Window:Tab({ Title = "Tavern", Icon = "beer", }) local HuntTab = Window:Tab({ Title = "Hunt", Icon = "target", }) local DiagnosticsTab = Window:Tab({ Title = "Diagnostics", Icon = "scan-search", }) local SettingsTab = Window:Tab({ Title = "Settings", Icon = "settings", }) --================================================== -- UI HELPERS --================================================== local function addSection(tab, title) local ok = pcall(function() tab:Section({ Title = title }) end) if not ok then pcall(function() tab:Paragraph({ Title = title, Desc = "" }) end) end end local function tryElement(description, fn) local ok, err = pcall(fn) if not ok then addLog("UI element failed (" .. description .. "): " .. tostring(err)) end end --================================================== -- DASHBOARD --================================================== Dashboard:Paragraph({ Title = "Tavern Town Inspector AIO", Desc = "Version " .. VERSION .. " | WindUI " .. WINDUI_VERSION, }) Dashboard:Paragraph({ Title = "Quick Start", Desc = "Pick animals in the Wildlife tab. The Tavern tab finds your tavern and plot and holds the experimental automation. Auto refresh is always on. Toggle this window with RightShift or RightControl.", }) Dashboard:Button({ Title = "Rescan Now", Icon = "refresh-cw", Callback = function() requestScan() safeNotify("Scan", "Rescan requested.") end, }) Dashboard:Button({ Title = "Print Full Report", Icon = "file-text", Callback = function() printReport() safeNotify("Report", "Report printed to console.") end, }) Dashboard:Button({ Title = "Show Event Logs", Icon = "scroll-text", Callback = printLogs, }) --================================================== -- WILDLIFE TAB --================================================== addSection(WildlifeTab, "Animal ESP") WildlifeTab:Toggle({ Title = "Show Animal ESP", Value = WildState.Enabled, Callback = function(value) WildState.Enabled = value requestScan() addLog("Animal ESP: " .. tostring(value)) end, }) WildlifeTab:Toggle({ Title = "Enable Animal Labels", Value = Settings.Labels, Callback = function(value) Settings.Labels = value addLog("Animal labels: " .. tostring(value)) end, }) WildlifeTab:Toggle({ Title = "Enable Highlights (nearest 30)", Value = Settings.Highlights, Callback = function(value) Settings.Highlights = value addLog("Highlights: " .. tostring(value)) end, }) tryElement("distance slider", function() WildlifeTab:Slider({ Title = "Max Distance", Step = 50, Value = { Min = 50, Max = 5000, Default = WildState.MaxDistance, }, Callback = function(value) local number = tonumber(value) if number then WildState.MaxDistance = number requestScan() end end, }) end) addSection(WildlifeTab, "Species (turn off the ones you don't want)") local SpeciesToggles = {} for _, species in ipairs(SPECIES_LIST) do local title = species.Name .. " - " .. species.Price if species.Note then title = title .. " (" .. species.Note .. ")" end tryElement(species.Name .. " toggle", function() SpeciesToggles[species.Name] = WildlifeTab:Toggle({ Title = title, Value = true, Callback = function(value) WildState.Selected[species.Name] = value requestScan() end, }) end) end local function setAllSpecies(value) for _, species in ipairs(SPECIES_LIST) do WildState.Selected[species.Name] = value local toggle = SpeciesToggles[species.Name] if toggle then pcall(function() toggle:Set(value) end) end end requestScan() end WildlifeTab:Button({ Title = "Select All Species", Icon = "check-check", Callback = function() setAllSpecies(true) addLog("All species enabled.") end, }) WildlifeTab:Button({ Title = "Deselect All Species", Icon = "x", Callback = function() setAllSpecies(false) addLog("All species disabled.") end, }) WildlifeTab:Button({ Title = "Print Species Census", Icon = "bar-chart", Callback = speciesCensus, }) --================================================== -- TAVERN TAB --================================================== addSection(TavernTab, "Your Tavern") InfoParagraph = TavernTab:Paragraph({ Title = "Owner Info", Desc = ownerInfoText(), }) TavernTab:Button({ Title = "Detect Tavern & Plot", Icon = "search", Callback = function() task.spawn(function() pcall(detectTavern) pcall(detectPlot) updateOwnerInfo() printOwnerReport() safeNotify( "Owner Detection", (Owner.Tavern and "Tavern found. " or "Tavern NOT found. ") .. (Owner.Plot and (Owner.Plot.Name .. ".") or "Plot not detected.") ) end) end, }) addSection(TavernTab, "Automation (experimental, off by default)") local function setAuto(key, label, value) Auto[key] = value addLog(label .. ": " .. tostring(value)) if value then if type(fireproximityprompt) ~= "function" and type(fireclickdetector) ~= "function" then addLog("Warning: executor has no fireproximityprompt / fireclickdetector.") end if not Owner.Tavern and not Owner.Plot then addLog("Warning: no tavern or plot detected yet, automation has nothing to work on.") end end end TavernTab:Toggle({ Title = "Auto Serve Drinks", Value = false, Callback = function(value) setAuto("Serve", "Auto Serve", value) end, }) TavernTab:Toggle({ Title = "Auto Collect Empty Mugs", Value = false, Callback = function(value) setAuto("Collect", "Auto Collect", value) end, }) TavernTab:Toggle({ Title = "Auto Wash Mugs", Value = false, Callback = function(value) setAuto("Wash", "Auto Wash", value) end, }) tryElement("action delay slider", function() TavernTab:Slider({ Title = "Action Delay (seconds)", Step = 0.1, Value = { Min = 0.2, Max = 3, Default = Settings.ActionDelay, }, Callback = function(value) local number = tonumber(value) if number then Settings.ActionDelay = number end end, }) end) tryElement("wash batch slider", function() TavernTab:Slider({ Title = "Wash After N Mugs", Step = 1, Value = { Min = 1, Max = 10, Default = Settings.WashBatch, }, Callback = function(value) local number = tonumber(value) if number then Settings.WashBatch = math.floor(number) end end, }) end) TavernTab:Toggle({ Title = "Teleport instead of walking", Value = Settings.AutoTeleport, Callback = function(value) Settings.AutoTeleport = value addLog("Auto teleport: " .. tostring(value)) end, }) TavernTab:Button({ Title = "Wash Now (one mug)", Icon = "droplets", Callback = function() task.spawn(function() refreshTargets() local target = pickTarget("Wash") if not target then addLog("Wash Now: no wash target found.") return end if interact(target, true) then Auto.Stats.Washed += 1 Auto.PendingMugs = math.max(0, Auto.PendingMugs - 1) end end) end, }) TavernTab:Button({ Title = "Print Automation Status", Icon = "activity", Callback = printAutomationStatus, }) addSection(TavernTab, "Scan Tools (print to console)") TavernTab:Button({ Title = "Interactable Census", Icon = "mouse-pointer-click", Callback = function() task.spawn(interactableCensus) end, }) TavernTab:Button({ Title = "Dump Tavern Structure", Icon = "folder-tree", Callback = function() dumpTree("TAVERN STRUCTURE", Owner.Tavern, 3, 400) end, }) TavernTab:Button({ Title = "Dump Bar Structure", Icon = "beer", Callback = function() local bar = findDescendantLike(tavernRoots(), "starterbar") if not bar then addLog("Bar (starterBar) not found in your tavern/plot.") end dumpTree("BAR STRUCTURE", bar, 5, 300) end, }) TavernTab:Button({ Title = "Dump Plot Structure", Icon = "map", Callback = function() dumpTree("PLOT STRUCTURE", Owner.Plot, 2, 300) local sign = findDescendantLike({ Owner.Plot }, "ownersign") if sign then dumpTree("OWNER SIGN", sign, 4, 100) end end, }) TavernTab:Button({ Title = "Dump Guests Folder", Icon = "users", Callback = function() dumpTree("GUESTS FOLDER", findChildCI(Workspace, "Guests"), 0, 100) end, }) --================================================== -- HUNT TAB --================================================== addSection(HuntTab, "Animal Auto Farm (experimental, off by default)") HuntTab:Paragraph({ Title = "How it works", Desc = "Hunts the animals switched ON in the Wildlife tab (known species only). It walks to the nearest one, equips a weapon, attacks until it dies, then looks for a collect prompt near the body.", }) HuntTab:Toggle({ Title = "Auto Hunt", Value = false, Callback = function(value) Hunt.Enabled = value addLog("Auto Hunt: " .. tostring(value)) if value then local character = LocalPlayer.Character if not character or not character:FindFirstChildOfClass("Tool") then addLog("Hunt: no tool equipped yet, it will try to equip one from your backpack.") end -- The menu would swallow the M1 clicks, so hide it. if Settings.HideMenuWhileHunting and windowOpen then toggleWindow() addLog("Menu hidden while hunting. Press RightShift to show it again.") end else task.delay(0.3, restoreHuntState) end end, }) HuntTab:Toggle({ Title = "Hide Menu While Hunting", Value = Settings.HideMenuWhileHunting, Callback = function(value) Settings.HideMenuWhileHunting = value end, }) HuntTab:Toggle({ Title = "Boost Walk Speed While Hunting", Value = Settings.HuntBoostSpeed, Callback = function(value) Settings.HuntBoostSpeed = value addLog("Hunt speed boost: " .. tostring(value)) end, }) tryElement("hunt walk speed slider", function() HuntTab:Slider({ Title = "Hunt Walk Speed", Step = 1, Value = { Min = 16, Max = 40, Default = Settings.HuntWalkSpeed, }, Callback = function(value) local number = tonumber(value) if number then Settings.HuntWalkSpeed = number end end, }) end) HuntTab:Toggle({ Title = "Collect Bodies After Kill", Value = Settings.CollectBodies, Callback = function(value) Settings.CollectBodies = value end, }) HuntTab:Toggle({ Title = "Skip Hostile Animals (Bear / Wolf)", Value = Settings.SkipHostile, Callback = function(value) Settings.SkipHostile = value addLog("Skip hostile: " .. tostring(value)) end, }) tryElement("hunt radius slider", function() HuntTab:Slider({ Title = "Hunt Radius (studs)", Step = 25, Value = { Min = 50, Max = 1000, Default = Settings.HuntRadius, }, Callback = function(value) local number = tonumber(value) if number then Settings.HuntRadius = number end end, }) end) tryElement("attack reach slider", function() HuntTab:Slider({ Title = "Attack Reach (studs)", Step = 1, Value = { Min = 3, Max = 20, Default = Settings.HuntReach, }, Callback = function(value) local number = tonumber(value) if number then Settings.HuntReach = number end end, }) end) tryElement("min health slider", function() HuntTab:Slider({ Title = "Pause Below Health %", Step = 5, Value = { Min = 0, Max = 90, Default = Settings.HuntMinHealth, }, Callback = function(value) local number = tonumber(value) if number then Settings.HuntMinHealth = number end end, }) end) tryElement("weapon input", function() HuntTab:Input({ Title = "Weapon Name (optional)", Value = "", Placeholder = "e.g. Spear (blank = auto)", Callback = function(text) Settings.WeaponName = tostring(text or "") addLog("Weapon name: " .. (Settings.WeaponName == "" and "(auto)" or Settings.WeaponName)) end, }) end) addSection(HuntTab, "Bow (hold M1 to draw, release to shoot)") HuntTab:Toggle({ Title = "Bow Mode", Value = Settings.BowMode, Callback = function(value) Settings.BowMode = value addLog("Bow mode: " .. tostring(value)) end, }) tryElement("bow range slider", function() HuntTab:Slider({ Title = "Bow Range (studs)", Step = 5, Value = { Min = 20, Max = 150, Default = Settings.BowRange, }, Callback = function(value) local number = tonumber(value) if number then Settings.BowRange = number end end, }) end) tryElement("bow draw time slider", function() HuntTab:Slider({ Title = "Draw Time (seconds)", Step = 0.1, Value = { Min = 0.2, Max = 3, Default = Settings.BowCharge, }, Callback = function(value) local number = tonumber(value) if number then Settings.BowCharge = number end end, }) end) tryElement("bow cooldown slider", function() HuntTab:Slider({ Title = "Time Between Shots (seconds)", Step = 0.1, Value = { Min = 0.3, Max = 3, Default = Settings.BowCooldown, }, Callback = function(value) local number = tonumber(value) if number then Settings.BowCooldown = number end end, }) end) tryElement("arrow speed slider", function() HuntTab:Slider({ Title = "Arrow Speed (studs/s)", Step = 10, Value = { Min = 50, Max = 500, Default = Settings.BowSpeed, }, Callback = function(value) local number = tonumber(value) if number then Settings.BowSpeed = number end end, }) end) tryElement("arc compensation slider", function() HuntTab:Slider({ Title = "Arc Compensation (%)", Step = 5, Value = { Min = 0, Max = 200, Default = Settings.BowArc, }, Callback = function(value) local number = tonumber(value) if number then Settings.BowArc = number end end, }) end) tryElement("cursor offset slider", function() HuntTab:Slider({ Title = "Aim Cursor Y Offset (pixels)", Step = 2, Value = { Min = -60, Max = 60, Default = Settings.AimOffsetY, }, Callback = function(value) local number = tonumber(value) if number then Settings.AimOffsetY = number end end, }) end) addSection(HuntTab, "Hunt Tools (print to console)") HuntTab:Button({ Title = "Print Hunt Status", Icon = "activity", Callback = printHuntStatus, }) HuntTab:Button({ Title = "Body Scan (stand next to a dead animal)", Icon = "scan", Callback = bodyScan, }) HuntTab:Button({ Title = "Print My Tools", Icon = "wrench", Callback = printTools, }) --================================================== -- DIAGNOSTICS --================================================== DiagnosticsTab:Paragraph({ Title = "Runtime Diagnostics", Desc = "Everything prints to the executor console (F9).", }) DiagnosticsTab:Button({ Title = "Distance Debug", Icon = "ruler", Callback = distanceDebug, }) DiagnosticsTab:Button({ Title = "Species Census", Icon = "bar-chart", Callback = speciesCensus, }) DiagnosticsTab:Button({ Title = "Inspect Nearest Animal", Icon = "crosshair", Callback = inspectNearest, }) DiagnosticsTab:Button({ Title = "Inspect Wildlife Folder", Icon = "folder-search", Callback = function() inspectFolder("Wildlife") end, }) DiagnosticsTab:Button({ Title = "Inspect World Folder", Icon = "globe", Callback = function() inspectFolder("World") end, }) DiagnosticsTab:Button({ Title = "Run Environment Diagnostics", Icon = "scan", Callback = function() local checks = { { "WindUI loaded", WindUI ~= nil }, { "CreateWindow available", type(WindUI.CreateWindow) == "function" }, { "LocalPlayer available", LocalPlayer ~= nil }, { "Workspace available", Workspace ~= nil }, { "RunService available", RunService ~= nil }, { "Visual container", Container ~= nil and Container.Parent ~= nil }, { "Wildlife folder available", findFolder("Wildlife") ~= nil }, { "World folder available", findFolder("World") ~= nil }, { "Guests folder available", findChildCI(Workspace, "Guests") ~= nil }, { "Plots folder available", findChildCI(Workspace, "Plots") ~= nil }, { "Your tavern found", Owner.Tavern ~= nil }, { "Your plot detected", Owner.Plot ~= nil }, { "fireproximityprompt available", type(fireproximityprompt) == "function" }, { "fireclickdetector available", type(fireclickdetector) == "function" }, { "Window:Toggle available", type(Window.Toggle) == "function" }, { "Window:Open available", type(Window.Open) == "function" }, { "Window:Close available", type(Window.Close) == "function" }, } print("\n========== ENVIRONMENT DIAGNOSTICS ==========") for _, check in ipairs(checks) do print(check[1] .. ":", check[2] and "PASS" or "FAIL") end print("PlaceId:", game.PlaceId) print("GameId:", game.GameId) print("==============================================\n") addLog("Environment diagnostics completed.") safeNotify("Diagnostics", "Diagnostics printed to console.") end, }) DiagnosticsTab:Button({ Title = "Print Runtime Information", Icon = "terminal", Callback = function() print("\n========== RUNTIME INFORMATION ==========") print("Version:", VERSION) print("WindUI:", WINDUI_VERSION) print("Player:", LocalPlayer and LocalPlayer.Name or "Unavailable") print("PlaceId:", game.PlaceId) print("GameId:", game.GameId) print("Elapsed:", os.clock() - startedAt) print("==========================================\n") addLog("Runtime information printed.") end, }) DiagnosticsTab:Button({ Title = "Show Event Logs", Icon = "scroll-text", Callback = printLogs, }) --================================================== -- SETTINGS --================================================== SettingsTab:Paragraph({ Title = "General Settings", Desc = "Auto refresh is always on and cannot be turned off.", }) SettingsTab:Toggle({ Title = "Show Price", Value = Settings.ShowPrice, Callback = function(value) Settings.ShowPrice = value end, }) SettingsTab:Toggle({ Title = "Show Notes (hostile / hits)", Value = Settings.ShowNotes, Callback = function(value) Settings.ShowNotes = value end, }) SettingsTab:Toggle({ Title = "Show Distance", Value = Settings.ShowDistance, Callback = function(value) Settings.ShowDistance = value end, }) SettingsTab:Toggle({ Title = "Show Health (when available)", Value = Settings.ShowHealth, Callback = function(value) Settings.ShowHealth = value end, }) tryElement("scan interval slider", function() SettingsTab:Slider({ Title = "Refresh Interval (seconds)", Step = 0.5, Value = { Min = 0.5, Max = 5, Default = Settings.ScanInterval, }, Callback = function(value) local number = tonumber(value) if number then Settings.ScanInterval = number end end, }) end) SettingsTab:Toggle({ Title = "Notifications", Value = CONFIG.Notifications, Callback = function(value) CONFIG.Notifications = value addLog("Notifications: " .. tostring(value)) if value then notify("Settings", "Notifications enabled.") end end, }) SettingsTab:Button({ Title = "Clear Event Logs", Icon = "trash-2", Callback = function() table.clear(State.Logs) log("Event logs cleared.") safeNotify("Logs", "Event logs cleared.") end, }) SettingsTab:Button({ Title = "Print Configuration", Icon = "settings-2", Callback = function() print("\n========== CONFIGURATION ==========") for key, value in pairs(CONFIG) do print(key, value) end for key, value in pairs(Settings) do print("Settings." .. key, value) end print("WildState.Enabled", WildState.Enabled) print("WildState.MaxDistance", WildState.MaxDistance) for _, species in ipairs(SPECIES_LIST) do print("Species." .. species.Name, WildState.Selected[species.Name]) end print("===================================\n") end, }) --================================================== -- BACKGROUND LOOPS --================================================== -- Auto refresh loop (always on): finds new animals and removes gone ones. task.spawn(function() while State.Running do if State.ScanDirty or os.clock() - State.LastScanClock >= Settings.ScanInterval then State.ScanDirty = false State.LastScanClock = os.clock() local ok, err = pcall(scanAll) if not ok then addLog("Auto refresh error: " .. tostring(err)) end end task.wait(0.25) end end) -- Update loop: distances, health text, highlight ranking. task.spawn(function() while State.Running do local ok, err = pcall(updateEntries) if not ok then addLog("Update error: " .. tostring(err)) end task.wait(0.25) end end) -- Owner loop: keeps trying to find your tavern / plot until found, -- and re-detects if they get replaced. task.spawn(function() while State.Running do local changed = false if not Owner.Tavern or not Owner.Tavern.Parent then local before = Owner.Tavern pcall(detectTavern) if Owner.Tavern ~= before then changed = true addLog("Tavern: " .. (Owner.Tavern and Owner.Tavern.Name or "lost")) end end if not Owner.Plot or not Owner.Plot.Parent then local before = Owner.Plot pcall(detectPlot) if Owner.Plot ~= before then changed = true addLog("Plot: " .. (Owner.Plot and (Owner.Plot.Name .. " (" .. tostring(Owner.PlotReason) .. ")") or "lost")) end end if changed then updateOwnerInfo() end for _ = 1, 20 do if not State.Running then break end task.wait(0.5) end end end) -- Automation loop (only does anything while a toggle is on). task.spawn(function() while State.Running do if Auto.Serve or Auto.Collect or Auto.Wash then local ok, err = pcall(automationStep) if not ok then addLog("Automation error: " .. tostring(err)) end end task.wait(Settings.ActionDelay) end end) -- Hunt loop (only does anything while Auto Hunt is on). task.spawn(function() while State.Running do if Hunt.Enabled then local ok, err = pcall(huntStep) if not ok then addLog("Hunt error: " .. tostring(err)) task.wait(1) end end task.wait(0.3) end end) -- Walk speed loop: while hunting, keeps WalkSpeed at the chosen value -- (the game may reset it); puts it back when hunting stops. task.spawn(function() while State.Running do local _, humanoid = getCharacterParts() if Hunt.Enabled and Settings.HuntBoostSpeed then if humanoid then if Hunt.OriginalSpeed == nil and humanoid.WalkSpeed ~= Settings.HuntWalkSpeed then Hunt.OriginalSpeed = humanoid.WalkSpeed end if humanoid.WalkSpeed ~= Settings.HuntWalkSpeed then pcall(function() humanoid.WalkSpeed = Settings.HuntWalkSpeed end) end end elseif Hunt.OriginalSpeed then if humanoid then pcall(function() humanoid.WalkSpeed = Hunt.OriginalSpeed end) end Hunt.OriginalSpeed = nil end task.wait(0.2) end end) --================================================== -- CLEANUP / UNLOAD --================================================== local function unload() if not State.Running then return end State.Running = false Auto.Serve = false Auto.Collect = false Auto.Wash = false Hunt.Enabled = false pcall(restoreHuntState) if ENV[INSTANCE_KEY] and ENV[INSTANCE_KEY].Unload == unload then ENV[INSTANCE_KEY] = nil end clearAllEntries() disconnectAll() if Container then pcall(function() Container:Destroy() end) end addLog("Inspector unloading.") local destroyed = false for _, methodName in ipairs({ "Destroy", "Close" }) do local method = Window and Window[methodName] if type(method) == "function" then local ok = pcall(function() method(Window) end) if ok then destroyed = true break end end end if not destroyed then warn("[Tavern Inspector] Window cleanup method unavailable.") end print("[Tavern Inspector] Unload completed.") end -- Register this instance so the next execution can replace it. ENV[INSTANCE_KEY] = { Unload = unload } SettingsTab:Button({ Title = "Unload UI", Icon = "power", Callback = unload, }) --================================================== -- READY --================================================== addLog("Tavern Town Inspector AIO v" .. VERSION .. " initialized.") safeNotify( "Tavern Inspector", "AIO v" .. VERSION .. " loaded successfully.", 5 ) print("[Tavern Inspector] AIO v" .. VERSION .. " loaded.") print("[Tavern Inspector] Auto refresh: ALWAYS ON.") print("[Tavern Inspector] Automation is OFF by default (Tavern tab).")