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

