How would I close the invite players menu with a script?

Hello, I made one of those Invite Friend menu buttons but I’m just wondering how I would close it if I clicked the button again. Is it possible to close it with a script or do I have to close it with the x button that’s on the invite menu?

Here’s a photo of what Menu I’m wanting to close if you don’t know what I’m talking about.
image

Can’t close that menu with code, it must be closed manually with the X button. Do you need something specific to happen when the menu closes or do you just want to control when its visible?

Oof :frowning: Just control when its visible.

Thanks!