My buttons are identifier undefined when I am trying to use them in a function

I am trying to create a function that can hide and show all of my buttons at once, but all the buttons are coming up undefined in the function even thought the button.setVisible() works fine when it is in an onClick lambda. Why is this happening?
Here is my code.:
PluginEditor.cpp

InstrumentLibraryOneAudioProcessorEditor::InstrumentLibraryOneAudioProcessorEditor (InstrumentLibraryOneAudioProcessor& p)
    : AudioProcessorEditor (&p), audioProcessor (p), processor(p)
{

    addAndMakeVisible(exitButton);
    addAndMakeVisible(productsButton);
    addAndMakeVisible(samplerButton);
    addAndMakeVisible(FXButton);
    addAndMakeVisible(chordButton);
    addAndMakeVisible(layerButton);
    addAndMakeVisible(insButton);
    addAndMakeVisible(backButton);
    addAndMakeVisible(nextButton);
    addAndMakeVisible(settingButton);

PluginEditor.h

private:
    // This reference is provided as a quick way for your editor to
    // access the processor object that created it.
    InstrumentLibraryOneAudioProcessor& audioProcessor;

    juce::TextButton exitButton{"Exit"};
    juce::TextButton productsButton{ "Products" };
    juce::TextButton samplerButton{ "Sampler" };
    juce::TextButton FXButton{ "FX" };
    juce::TextButton chordButton{ "Chords" };
    juce::TextButton layerButton{ "Layering" };
    juce::TextButton insButton{ "Instruments" };
    juce::TextButton backButton{ "Back" };
    juce::TextButton nextButton{ "Next" };
    juce::TextButton settingButton{ "Settings" };

    InstrumentLibraryOneAudioProcessor& processor;
    JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (InstrumentLibraryOneAudioProcessorEditor)
};

PluginProcessor.cpp

void InstrumentLibraryOneAudioProcessor::makeAllVisible(bool visibility)
{
    productsButton.setVisible(visibility);
    samplerButton.setVisible(visibility);
    FXButton.setVisible(visibility);
    chordButton.setVisible(visibility);
    layerButton.setVisible(visibility);
    insButton.setVisible(visibility);
    settingButton.setVisible(visibility);
    backButton.setVisible(visibility);
    nextButton.setVisible(visibility);
}

pluginProcessor.h

void getStateInformation (juce::MemoryBlock& destData) override;
    void setStateInformation (const void* data, int sizeInBytes) override;

    void loadFile();
    void changePage(string page);
    void makeAllVisible(bool visibility);
    float attack = 0.1;
    float release = 0.1;
    string currentPage = "Home";

The processor “lives longer” than the editor, you should not do anything related to specific editor functionality in the processor. When the processor receives the state from the host, there is typically not yet an editor created/opened.

I see that you have the buttons declared in the editor, which is OK of course, but I do not see how your processor can access them in its makeAllVisible method.

Have you maybe declared references to them in the processor, which is not shown here?

The onClick handler you mention “lives” in the editor, so there the buttons are accessible (created).