function ScopeHUD.BuildScopeHierarchyButtons(T)local N={}local e={}local E=T.state.ScopeTarget or T.state.Scope while E~=nil and E~=Workspace.Parent do table.insert(N,1,E)E=E.Parent end for N,E in ipairs(N)do e[N]=new(ScopeHierarchyItemButton,{Instance=E,IsTarget=T.state.ScopeTarget==E;IsScopeParent=T.state.Scope and T.state.Scope.Parent==E,IsScope=T.state.Scope==E;IsScopable=T.state.ScopeTarget==E and IsItemScopable(E);IsScopeLocked=T.state.IsScopeLocked;SetScopeFromButton=T.SetScopeFromButton;IsAltDown=T.state.IsAltDown;LayoutOrder=N+1})end if not T.state.IsAltDown then e[#N+1]=new(HotkeyTooltip,{IsAltDown=false,DisplayAltHotkey=UserInputService.KeyboardEnabled,LayoutOrder=#N+2})end return e end return ScopeHUD

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
