local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local UserInputService = game:GetService("UserInputService")
local RunService = game:GetService("RunService")
local StarterGui = game:GetService("StarterGui")

local LocalPlayer = Players.LocalPlayer

local COUNT_DESCENDANTS = true
local Y_OFFSET = 5
local TOGGLE_UI_KEY = Enum.KeyCode.H
local RENDER_TAG = "ForceMouseDefaultWhenUnlocked"

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")

local function safeNotify(props)
	local ok = pcall(function()
		StarterGui:SetCore("SendNotification", props)
	end)
	if not ok then
		task.spawn(function()
			task.wait(1)
			pcall(function()
				StarterGui:SetCore("SendNotification", props)
			end)
		end)
	end
end

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

local Window = WindUI:CreateWindow({
	Title = "Loot Manager",
	Icon = "box",
	Theme = "Dark",
	Size = UDim2.fromOffset(620, 520),
})
Window:SetToggleKey(Enum.KeyCode.H)
local ButtonRefs = {}

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 = "Bring all items of this name to player",
				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

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

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

local player = LocalPlayer
local playerScripts = player:WaitForChild("PlayerScripts")
local PlayerModule = require(playerScripts:WaitForChild("PlayerModule"))
local Controls = PlayerModule:GetControls()

player.CameraMode = Enum.CameraMode.LockFirstPerson
local unlocked = false

local function forceDefaultEachFrame(enable)
	if enable then
		RunService:BindToRenderStep(RENDER_TAG, Enum.RenderPriority.Camera.Value + 1, function()
			if unlocked then
				UserInputService.MouseBehavior = Enum.MouseBehavior.Default
			end
		end)
	else
		RunService:UnbindFromRenderStep(RENDER_TAG)
	end
end

local function setUnlocked(on)
	unlocked = on
	if unlocked then
		Controls:Disable()
		UserInputService.MouseIconEnabled = true
		UserInputService.MouseBehavior = Enum.MouseBehavior.Default
		forceDefaultEachFrame(true)
	else
		forceDefaultEachFrame(false)
		UserInputService.MouseIconEnabled = false
		UserInputService.MouseBehavior = Enum.MouseBehavior.LockCenter
		Controls:Enable()
	end

	safeNotify({
		Title = unlocked and "Mouse Unlocked" or "Mouse Locked",
		Text = unlocked and "Mouse free / camera paused" or "Mouse locked / camera enabled",
		Duration = 3
	})

	print("UnlockMouse:", unlocked)
end

UserInputService.InputBegan:Connect(function(input, gpe)
	if gpe then return end

	if input.KeyCode == TOGGLE_UI_KEY then
		setUnlocked(not unlocked)
	elseif input.KeyCode == TOGGLE_UI_KEY then
		local frame = Window:GetMainFrame()
		if frame then
			frame.Visible = not frame.Visible
			safeNotify({
				Title = "Loot Manager",
				Text = frame.Visible and "UI opened" or "UI hidden",
				Duration = 2
			})
		end
	end
end)

UserInputService.WindowFocusReleased:Connect(function()
	if unlocked then
		UserInputService.MouseBehavior = Enum.MouseBehavior.Default
		UserInputService.MouseIconEnabled = true
	end
end)

setUnlocked(true)

safeNotify({
	Title = "Controls",
	Text = ("Press %s to toggle mouse | Press %s to toggle UI"):format(TOGGLE_UI_KEY.Name, TOGGLE_UI_KEY.Name),
	Duration = 7
})
[☢️] Build a Bunker! Build a Bunker!
8,760 views
11 months ago

Build a Bunker!

WORKING
Free

Description

loadstring(game:HttpGet('https://haxhell.com/api/raw/build-a-bunker-build-a-bunker'))()*

🖱️ Controls

Press H:

🔓 Unlock Mouse - Mouse moves freely, camera paused

🔒 Lock Mouse - Mouse locked to center, camera enabled

Press H:

👁️ Toggle UI - Show or hide Loot Manager window

Related Scripts