How to pause a game including physics, scripts, gui's, etc

Im currently attempting a Pause menu for my upcoming game due to an issue that if you die our game does not save. The menu would act as a way to get back to the main menu as well as change settings while still in the game.

I tried doing some research on the topic and can’t find anything besides plugins being able to run and stop a game. { RunService:Pause() }

It’d be helpful if you could help me out on this one.

3 Likes

You can’t pause everything. What you could do, however, is anchor all the parts in the world (save them for later so you can unanchor them when unpaused). Then, stop running code in any loops (simple if statement to see if game is paused).

There is no way to “Pause” the game in the way you want outside of studio.

As for data not saving when you reset, you could just prevent the player from resting:

game:GetService("StarterGui"):SetCore("ResetButtonCallback", false)
2 Likes

Unfortunately, there’s no one function you can run to do this outside of Studio. However, all scripts have a Disabled property that you can use to disable them (the benefit to this is that you can disable certain scripts and not others), and you can anchor all parts in the game to disable physics.

Even if a complete pause was possible, it would make impossible to unpause the game since all scripts are paused.

3 Likes

While this could be a viable solution, disabling scripts has side-effects. For example, say you attached functions like .CharacterAdded through .PlayerAdded. This would stop working, as the script would disconnect everything and run from the start. If you have a data loading system, it would reload all the data over again. If you had a round system, it would reset. This is impractical and there are better solutions than just brute force disabling scripts.

I would reccomend using conditions to prevent execution of certain bits of code. That way, you don’t disable your entire script, and can exclude certain things (you want your unpaid button to work).

3 Likes

Only possible ways are a)manually disable scrip and all you want to stop
b)extremely lag it

2 Likes