1. I've been spinning my wheels all day trying to get a frame to hide. The frame is from addon Bazooka and is called BazookaBar_1 when I use /framestack.

    When I try to hide it I get an error attempt to index global BazookaBar1 a nil value. Below is my current code. I've tried Bazooka.BazookaBar1 as well. How do I make a frame from another addon local? Or is there a better way to do this? Thanks in advance.

     local function topmenudisplay()
     if TopmenuShow == 1 then
     topmenu:Show()
     topmenuborder:Show()
     BazookaBar_1:Show()
    
     end
    
     if TopmenuShow == nil then
     topmenu:Hide()
     topmenuborder:Hide()
     BazookaBar_1:Hide()
     end
     end
    

    You don't have to make it local, you can just refer to it using the global name, if it has one.

     /dump GetMouseFocus():GetName()
    

    Then to try and hide it:

     /run _G[GetMouseFocus():GetName()]:Hide()
    

    if I type the command in chat window it works fine. I get same error when I added it to the

     function.
     function topmenudisplay()
    
     if TopmenuShow == 1 then
     topmenu:Show()
     topmenuborder:Show()
     _G["BazookaBar_1"]:Show()
     else
     if TopmenuShow == nil then
     topmenu:Hide()
     topmenuborder:Hide()
     _G["BazookaBar_1"]:Hide()
     end
     end
     end
    

    The frame probably doesn't exist at that point. You have to wait until everything's been initialized and loaded.

    I have Bazooka set as a dependency. Wouldn't everything be loaded before my addon?

    No. Many addons don't do things until after one of the loading events.

    Since the command works like I want it to. Should I suppress the error somehow or figure out a way to make sure the BazookBar_1 is initialized before running the function?

    I got the error to stop by changing the function to this. Seems like this will be a lot of overhead. Is there a better way to to it?

     topmenu:SetScript("OnEvent", function(self, event, ...)
     local timeleft = 1 --set the countdown to w/e you want
     local f = CreateFrame("Frame", nil, UIParent)
     f:SetScript("OnUpdate", function(_,arg)
       timeleft = timeleft - arg
       if timeleft >= 0 then
         timeleft = nil
         f:SetScript("OnUpdate", nil)
         topmenudisplay()
       end
     end)
     end)
    

    Two things, you should register the appropriate event and make sure that your code runs after the other code. There's no overhead to this.

    This just adds a static time. You would be better off waiting until one of the loading events and then checking and triggering a timer only if it still hasn't loaded.