local Players = game:GetService("Players") local ReplicatedStorage = game:GetService("ReplicatedStorage") local RunService = game:GetService("RunService") local Workspace = game:GetService("Workspace") local Player = Players.LocalPlayer local env = (getgenv and getgenv()) or _G -- повторный запуск = выключение if env.__InfiniteBackpack then for _, c in ipairs(env.__InfiniteBackpack) do if c and c.Connected then c:Disconnect() end end env.__InfiniteBackpack = nil warn("[Infinite Backpack] OFF") return end local connections = {} env.__InfiniteBackpack = connections local MapIngame = Workspace:WaitForChild("Map"):WaitForChild("Ingame") local LastDupeAt = 0 local DupeBlocked = {} local function holdsItem(itemName) local character = Player.Character local backpack = Player:FindFirstChild("Backpack") if backpack and backpack:FindFirstChild(itemName) then return true end if character and character:FindFirstChild(itemName) then return true end return false end local function inventoryCount(itemName) local count = 0 local backpack = Player:FindFirstChild("Backpack") if backpack then for _, child in ipairs(backpack:GetChildren()) do if child.Name == itemName then count += 1 end end end local character = Player.Character if character then for _, child in ipairs(character:GetChildren()) do if child.Name == itemName then count += 1 end end end return count end local function dropItemRemote(tool) local okNetwork, network = pcall(function() return require(ReplicatedStorage.Modules.Network.Network) end) if not okNetwork or not network then return false end return (pcall(function() network:FireServerConnection("DropItem", "REMOTE_EVENT", tool) end)) end -- выбрасываем все копии предмета, через 0.1 с подбираем все разом в один тик local function dupeConsumable(itemName) local now = os.clock() if now - LastDupeAt < 1.2 then return end LastDupeAt = now if (DupeBlocked[itemName] or 0) > now then return end task.spawn(function() local character = Player.Character local backpack = Player:FindFirstChild("Backpack") if not character or not backpack then return end local held = {} for _, child in ipairs(backpack:GetChildren()) do if child.Name == itemName then held[#held + 1] = child end end if #held == 0 then return end local beforeCount = #held for _, tool in ipairs(held) do dropItemRemote(tool) end task.wait(0.1) local mapFolder = Workspace:FindFirstChild("Map") local mapIngame = mapFolder and mapFolder:FindFirstChild("Ingame") local rootPart = character:FindFirstChild("HumanoidRootPart") if not mapIngame or not rootPart then return end for _, instance in ipairs(mapIngame:GetChildren()) do if instance.Name == itemName and instance:IsA("Tool") then local prompt = instance:FindFirstChildWhichIsA("ProximityPrompt", true) local part = instance:FindFirstChild("ItemRoot") or instance:FindFirstChildWhichIsA("BasePart", true) if prompt and part and part.Parent then local maxDistance = prompt.MaxActivationDistance or 12 if (rootPart.Position - part.Position).Magnitude <= maxDistance then pcall(fireproximityprompt, prompt, 1) end end end end task.wait(0.25) if inventoryCount(itemName) <= beforeCount then DupeBlocked[itemName] = os.clock() + 10 end end) end local cachedItems = setmetatable({}, { __mode = "k" }) local lastFire = setmetatable({}, { __mode = "k" }) local function pickupData(instance) if not instance or not instance.Parent then return nil end if instance:IsA("Tool") and (instance.Name == "BloxyCola" or instance.Name == "Medkit" or (instance.Name == "Fruit" and instance:GetAttribute("Fruit"))) then local root = instance:FindFirstChild("ItemRoot") local prompt = root and root:FindFirstChildOfClass("ProximityPrompt") if root and prompt then return root, prompt end elseif instance:IsA("Model") and instance.Name == "Gear" then if instance:FindFirstAncestor("GearsTest") then local root = instance:FindFirstChild("Root") or instance.PrimaryPart or instance:FindFirstChildWhichIsA("BasePart", true) local prompt = instance:FindFirstChildOfClass("ProximityPrompt") if root and prompt then return root, prompt end end end end local function ownerFrom(instance, map) local current = instance for _ = 1, 5 do if not current or current == map then break end if current:IsA("Tool") or current:IsA("Model") then local root, prompt = pickupData(current) if root then return current, root, prompt end end current = current.Parent end end local function bindMap(map) table.clear(cachedItems) if not map then return end local function track(instance) local owner, root, prompt = ownerFrom(instance, map) if owner and not cachedItems[owner] then cachedItems[owner] = { Root = root, Prompt = prompt } end end track(map) for _, instance in ipairs(map:GetDescendants()) do track(instance) end connections[#connections + 1] = map.DescendantAdded:Connect(track) connections[#connections + 1] = map.DescendantRemoving:Connect(function(instance) cachedItems[instance] = nil end) end -- выброшенные предметы лежат прямо в Map.Ingame, поэтому слушаем его целиком bindMap(MapIngame) connections[#connections + 1] = MapIngame.ChildAdded:Connect(function(child) if child.Name == "Map" then task.defer(function() if env.__InfiniteBackpack == connections and child.Parent then bindMap(child) end end) end end) local elapsed = 0 connections[#connections + 1] = RunService.Heartbeat:Connect(function(dt) elapsed += dt if elapsed < 0.1 then return end elapsed = 0 local character = Player.Character local humanoid = character and character:FindFirstChildOfClass("Humanoid") local rootPart = character and character:FindFirstChild("HumanoidRootPart") if not rootPart or not humanoid or humanoid.Health <= 0 or not character.Parent or character.Parent.Name ~= "Survivors" then return end local now, position = os.clock(), rootPart.Position for instance, data in pairs(cachedItems) do if not instance.Parent or not data.Root.Parent or not data.Prompt.Parent then cachedItems[instance] = nil else local distance = data.Prompt.MaxActivationDistance or 12 if (position - data.Root.Position).Magnitude <= distance then local itemName = instance.Name local isConsumable = itemName == "BloxyCola" or itemName == "Medkit" or itemName == "Fruit" if isConsumable then if holdsItem(itemName) then dupeConsumable(itemName) end if now - (lastFire[data.Prompt] or 0) >= 0.3 then lastFire[data.Prompt] = now for _ = 1, 5 do pcall(fireproximityprompt, data.Prompt, 1) end end elseif now - (lastFire[data.Prompt] or 0) >= 0.75 then lastFire[data.Prompt] = now pcall(fireproximityprompt, data.Prompt, 1) end end end end end) warn("[Infinite Backpack] ON")