EquippedVal.Changed:connect(function()for e,C in pairs(UiFrame:GetChildren())do if C:IsA("\073\109\097\103\101\066\117\116\116\111\110")then C.BorderSizePixel=1 end end if EquippedVal.Value then local e=UiFrame:FindFirstChild(EquippedVal.Value.Name)if e then e.BorderSizePixel=4 end end end)for e,C in pairs(UiFrame:GetChildren())do if C:IsA("\073\109\097\103\101\066\117\116\116\111\110")then C.MouseButton1Click:Connect(function()local e=SlotsFolder:FindFirstChild(C.Name)if e then if EquippedVal.Value==e then EquippedVal.Value=nil else EquippedVal.Value=e end end end)end end game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack,false)
-- Show highlight on currently equipped tool in toolbar
EquippedVal.Changed:connect(function()
	for i, v in pairs(UiFrame:GetChildren()) do
		if v:IsA("ImageButton") then
			v.BorderSizePixel = 1
		end
	end
	if EquippedVal.Value then
		local imageButton = UiFrame:FindFirstChild(EquippedVal.Value.Name)
		if imageButton then
			imageButton.BorderSizePixel = 4
		end
	end
end)

for i, v in pairs(UiFrame:GetChildren()) do
	if v:IsA("ImageButton") then
		v.MouseButton1Click:Connect(function()
			local slotRequested = SlotsFolder:FindFirstChild(v.Name)
			if slotRequested then -- if there is such a slot
				-- if they're requesting the same slot
				if EquippedVal.Value == slotRequested then
					EquippedVal.Value = nil -- unequip the tool
				else
					EquippedVal.Value = slotRequested -- equip the tool
				end
			end
		end)
	end
end

game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, false)
