Want to pause my game whenever the user enters Roblox's built-in chat or Esc menu

The “pausing” involved here is something handled on my end, and I have no trouble executing it.
My problem is that I want the game to pause automatically when the user’s input gets tied up in the built-in Roblox UIs: Esc menu and user chat.
Is there some type of method I can use to check to see if this is true? (the user being in these built-in UIs)

1 Like

Yes, there is actually. These functions are available within the GuiService as MenuOpened and MenuClosed.

7 Likes

How would one go about checking if a user is interacting with the chat menu?

I know that you can check if inputs are being used for the chat with the gameProcessedEvent parameter, so I imagine there must also be some official protocol that can tell me when the chat is opened.

1 Like

You will have to accomplish this by implementing your own custom behaviour. The chat system, as you may know, was ported to Lua, meaning that you can modify it in almost any way you so choose. There is a section in it that contains modules and such available for you - try searching through the ChatBar module.

SetCore has some useful methods you can use, but I don’t believe they’ll fully suit your needs. Typically when operating on the chat, you should have your scripts interact with the Lua Chat System. You can check out the ChatBar documentation, or the Lua Chat System documentation hub for assistance when editing the chat scripts or creating connections between your scripts and the chat system.

3 Likes

I would use the GuiService.MenuOpened/GuiService.MenuClosed functions to detect when the user goes to the hamburger menu (or whatever you call it)

As for the chat bar, you could fork the chat scripts (there are other threads on this) and use the TextBox.Focused event to detect whenever a user Focuses/leaves the Chat.

Please note that forking the chat script will cease all futher updates regarding the Chat. You run a risk of your script erroring if you don’t fork it (as names of objects are subject to change at any point).

Good luck!

2 Likes

You mean if you do fork it? Forking the chat script doesn’t necessarily produce errors, it just doesn’t fetch the latest version for use.

This is also a partially false statement; you can fork specific parts of the chat UI and any missing components will be automatically added if ChatService.LoadDefaultChat or one of those “InsertDefaultModules” BoolValues are in the folder with their value set to true. These forks will not receive updates, but the rest of the chat system will. Typically you should not be forking the entire chat framework unless you need to edit all modules.

There is a specific module for doing this, which I described in my post. Hard coding a line to try and get the chat bar from PlayerGui is not a good idea: the module gives you more accessibility over the ChatBar and includes a way to run code upon focus.

2 Likes