[☢️] Build a Bunker! Build a Bunker!
3,540 views
3 weeks 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

Script

RAW
1local Players = game:GetService("Players")
2local ReplicatedStorage = game:GetService("ReplicatedStorage")
3local UserInputService = game:GetService("UserInputService")
4local RunService = game:GetService("RunService")
5local StarterGui = game:GetService("StarterGui")
6
7local LocalPlayer = Players.LocalPlayer
8
9local COUNT_DESCENDANTS = true
10local Y_OFFSET = 5
11local TOGGLE_UI_KEY = Enum.KeyCode.H
12local RENDER_TAG = "ForceMouseDefaultWhenUnlocked"
13
14local Version = "1.6.41"
15local WindUI = loadstring(game:HttpGet("https://github.com/Footagesus/WindUI/releases/download/" .. Version .. "/main.lua"))()
16
17local LootRS = ReplicatedStorage:WaitForChild("Loot", 5)
18local WorldLoot = workspace:FindFirstChild("Loot")
19
20local function safeNotify(props)
21	local ok = pcall(function()
22		StarterGui:SetCore("SendNotification", props)
23	end)
24	if not ok then
25		task.spawn(function()
26			task.wait(1)
27			pcall(function()
28				StarterGui:SetCore("SendNotification", props)
29			end)
30		end)
31	end
32end
33
34local function readCategories()
35	local categories = {}
36	if not LootRS then return categories end
37	for _, cat in ipairs(LootRS:GetChildren()) do
38		if cat:IsA("Folder") then
39			local catName = cat.Name
40			categories[catName] = {}
41			for _, item in ipairs(cat:GetChildren()) do
42				categories[catName][item.Name] = 0
43			end
44		end
45	end
46	return categories
47end
48
49local function buildWorldCountMap()
50	local map = {}
51	if not WorldLoot then return map end
52	local list = COUNT_DESCENDANTS and WorldLoot:GetDescendants() or WorldLoot:GetChildren()
53	for _, inst in ipairs(list) do
54		map[inst.Name] = (map[inst.Name] or 0) + 1
55	end
56	return map
57end
58
59local function fillCounts(categories, worldMap)
60	for _, items in pairs(categories) do
61		for itemName in pairs(items) do
62			items[itemName] = worldMap[itemName] or 0
63		end
64	end
65end
66
67local function bringAllByName(itemName)
68	if not WorldLoot then return end
69	local char = LocalPlayer.Character or LocalPlayer.CharacterAdded:Wait()
70	local hrp = char:WaitForChild("HumanoidRootPart")
71	local targetCF = hrp.CFrame + Vector3.new(0, Y_OFFSET, 0)
72
73	local list = COUNT_DESCENDANTS and WorldLoot:GetDescendants() or WorldLoot:GetChildren()
74	for _, inst in ipairs(list) do
75		if inst.Name == itemName then
76			local obj = inst:FindFirstAncestorOfClass("Model") or inst
77			if obj:IsA("Model") then
78				if obj.PrimaryPart then
79					obj:PivotTo(targetCF)
80				else
81					local p = obj:FindFirstChildWhichIsA("BasePart", true)
82					if p then
83						obj.PrimaryPart = p
84						obj:PivotTo(targetCF)
85						obj.PrimaryPart = nil
86					end
87				end
88			else
89				local bp = obj:IsA("BasePart") and obj or obj:FindFirstChildWhichIsA("BasePart", true)
90				if bp then bp.CFrame = targetCF end
91			end
92		end
93	end
94end
95
96local Window = WindUI:CreateWindow({
97	Title = "Loot Manager",
98	Icon = "box",
99	Theme = "Dark",
100	Size = UDim2.fromOffset(620, 520),
101})
102Window:SetToggleKey(Enum.KeyCode.H)
103local ButtonRefs = {}
104
105local function buildUI(categories)
106	for catName, items in pairs(categories) do
107		local Tab = Window:Tab({
108			Title = catName,
109			Icon = "folder",
110		})
111
112		ButtonRefs[catName] = {}
113
114		local available, unavailable = {}, {}
115		for itemName, count in pairs(items) do
116			if count > 0 then
117				table.insert(available, {name = itemName, count = count})
118			else
119				table.insert(unavailable, {name = itemName, count = count})
120			end
121		end
122		local ordered = {}
123		for _, v in ipairs(available) do table.insert(ordered, v) end
124		for _, v in ipairs(unavailable) do table.insert(ordered, v) end
125
126		for _, data in ipairs(ordered) do
127			local btn = Tab:Button({
128				Title = string.format("%s  (%d)", data.name, data.count),
129				Desc = "Bring all items of this name to player",
130				Callback = function() bringAllByName(data.name) end,
131			})
132
133			if data.count <= 0 then
134				btn:Lock()
135			else
136				btn:Unlock()
137			end
138			ButtonRefs[catName][data.name] = btn
139		end
140	end
141end
142
143local function refreshUI(categories)
144	for catName, items in pairs(categories) do
145		for itemName, count in pairs(items) do
146			local btn = ButtonRefs[catName] and ButtonRefs[catName][itemName]
147			if btn then
148				btn:SetTitle(string.format("%s  (%d)", itemName, count))
149				if count > 0 then btn:Unlock() else btn:Lock() end
150			end
151		end
152	end
153end
154
155local Categories = readCategories()
156fillCounts(Categories, buildWorldCountMap())
157buildUI(Categories)
158
159if WorldLoot then
160	local function recalc()
161		fillCounts(Categories, buildWorldCountMap())
162		refreshUI(Categories)
163	end
164	WorldLoot.ChildAdded:Connect(recalc)
165	WorldLoot.ChildRemoved:Connect(recalc)
166	if COUNT_DESCENDANTS then
167		WorldLoot.DescendantAdded:Connect(recalc)
168		WorldLoot.DescendantRemoving:Connect(recalc)
169	end
170end
171
172local player = LocalPlayer
173local playerScripts = player:WaitForChild("PlayerScripts")
174local PlayerModule = require(playerScripts:WaitForChild("PlayerModule"))
175local Controls = PlayerModule:GetControls()
176
177player.CameraMode = Enum.CameraMode.LockFirstPerson
178local unlocked = false
179
180local function forceDefaultEachFrame(enable)
181	if enable then
182		RunService:BindToRenderStep(RENDER_TAG, Enum.RenderPriority.Camera.Value + 1, function()
183			if unlocked then
184				UserInputService.MouseBehavior = Enum.MouseBehavior.Default
185			end
186		end)
187	else
188		RunService:UnbindFromRenderStep(RENDER_TAG)
189	end
190end
191
192local function setUnlocked(on)
193	unlocked = on
194	if unlocked then
195		Controls:Disable()
196		UserInputService.MouseIconEnabled = true
197		UserInputService.MouseBehavior = Enum.MouseBehavior.Default
198		forceDefaultEachFrame(true)
199	else
200		forceDefaultEachFrame(false)
201		UserInputService.MouseIconEnabled = false
202		UserInputService.MouseBehavior = Enum.MouseBehavior.LockCenter
203		Controls:Enable()
204	end
205
206	safeNotify({
207		Title = unlocked and "Mouse Unlocked" or "Mouse Locked",
208		Text = unlocked and "Mouse free / camera paused" or "Mouse locked / camera enabled",
209		Duration = 3
210	})
211
212	print("UnlockMouse:", unlocked)
213end
214
215UserInputService.InputBegan:Connect(function(input, gpe)
216	if gpe then return end
217
218	if input.KeyCode == TOGGLE_UI_KEY then
219		setUnlocked(not unlocked)
220	elseif input.KeyCode == TOGGLE_UI_KEY then
221		local frame = Window:GetMainFrame()
222		if frame then
223			frame.Visible = not frame.Visible
224			safeNotify({
225				Title = "Loot Manager",
226				Text = frame.Visible and "UI opened" or "UI hidden",
227				Duration = 2
228			})
229		end
230	end
231end)
232
233UserInputService.WindowFocusReleased:Connect(function()
234	if unlocked then
235		UserInputService.MouseBehavior = Enum.MouseBehavior.Default
236		UserInputService.MouseIconEnabled = true
237	end
238end)
239
240setUnlocked(true)
241
242safeNotify({
243	Title = "Controls",
244	Text = ("Press %s to toggle mouse | Press %s to toggle UI"):format(TOGGLE_UI_KEY.Name, TOGGLE_UI_KEY.Name),
245	Duration = 7
246})

Comments

Related Scripts

No related scripts found