How can I see when a Frame changes its visibility state?

How can I see when a Frame changes its visibility state?

Frame:GetPropertyChangedSignal("Visible"):Connect(function()
    -- Fires when the "Visible" property value changes
end)
1 Like
local Frame = Instance.new("Frame")

-- Check if frame is visible or not
if Frame.Visible then
    -- Frame is visible
else
    -- Frame is not visible
end

If you’re looking to return a boolean then use this:

local function FrameIsVisible(ThetaFrame: Frame): boolean
    if ThetaFrame.Visible then
        return true
    else
        return false
    end
end
1 Like

The second function is not really neccessary since you can just read the Visible property from the object. (You can also simplify it to this:)

local function FrameIsVisible(ThetaFrame: Frame) : boolean
    return ThetaFrame.Visible
end

People, you dont have to do all this extra function stuff. This is the most simpliest and easy to read way, as well as it being the built in way of how you need to do it. If you run the function once as what @Midnightific did, it wont update real time, and to make it update real time, you would have to do a while loop. As to add to this answer, to check if its visible, you can just do this:

Frame:GetPropertyChangedSignal("Visible"):Connect(function()
   if Frame.Visible == true then
      -- visible
      else
      -- not visible
   end
end)
2 Likes

I’m aware but I wasn’t sure if they wanted to run a function or something if that condition was met so I left space for that, I should have made myself clearer. Sorry!