function ScopeHUD.BuildScopeHierarchyButtons(h)local n={}local i={}local o=h.state.ScopeTarget or h.state.Scope while o~=nil and o~=Workspace.Parent do table.insert(n,1,o)o=o.Parent end for n,o in ipairs(n)do i[n]=new(ScopeHierarchyItemButton,{Instance=o;IsTarget=h.state.ScopeTarget==o,IsScopeParent=h.state.Scope and h.state.Scope.Parent==o;IsScope=h.state.Scope==o;IsScopable=h.state.ScopeTarget==o and IsItemScopable(o),IsScopeLocked=h.state.IsScopeLocked,SetScopeFromButton=h.SetScopeFromButton,IsAltDown=h.state.IsAltDown;LayoutOrder=n+1})end if not h.state.IsAltDown then i[#n+1]=new(HotkeyTooltip,{IsAltDown=false;DisplayAltHotkey=UserInputService.KeyboardEnabled,LayoutOrder=#n+2})end return i end return ScopeHUD
--- Builds and returns a button for each item in the scope hierarchy.
-- @returns ScopeHierarchyItemButton[]
function ScopeHUD:BuildScopeHierarchyButtons()
	local Hierarchy = {}
	local Buttons = {}

	-- Navigate up hierarchy from scope target
	local CurrentScopePosition = self.state.ScopeTarget or self.state.Scope
	while (CurrentScopePosition ~= nil) and (CurrentScopePosition ~= Workspace.Parent) do
		table.insert(Hierarchy, 1, CurrentScopePosition)
		CurrentScopePosition = CurrentScopePosition.Parent
	end

	-- Create button for each scope hierarchy item
	for Index, ScopePosition in ipairs(Hierarchy) do
		Buttons[Index] = new(ScopeHierarchyItemButton, {
			Instance = ScopePosition,
			IsTarget = (self.state.ScopeTarget == ScopePosition),
			IsScopeParent = self.state.Scope and (self.state.Scope.Parent == ScopePosition),
			IsScope = (self.state.Scope == ScopePosition),
			IsScopable = (self.state.ScopeTarget == ScopePosition) and IsItemScopable(ScopePosition),
			IsScopeLocked = self.state.IsScopeLocked,
			SetScopeFromButton = self.SetScopeFromButton,
			IsAltDown = self.state.IsAltDown,
			LayoutOrder = Index + 1,
		})
	end

	-- Add hotkey tooltip if alt not held down
	if not self.state.IsAltDown then
		Buttons[#Hierarchy + 1] = new(HotkeyTooltip, {
			IsAltDown = false,
			DisplayAltHotkey = UserInputService.KeyboardEnabled,
			LayoutOrder = #Hierarchy + 2,
		})
	end

	-- Return list of buttons
	return Buttons
end

return ScopeHUD
