Pause my Game like in Studio?

Pausing may be a feature in Roblox Studio, but is it possible in game?

A lot of developers use the pause feature in Roblox Studio when they test their game. I was wondering if it was possible to do this in the actual game. I tried game:Pause()… Then I was out of ideas. game:Pause did not work.

The pause feature on Roblox is… interesting. It pauses the player, but does not pause the in-game scripts. As you can see in this video, the player isn’t moving, but the random number generator is still running.


Is it possible to do this in-game? If you can, let me know in a post! :grin:

1 Like

Unfortunately, you cannot pause the game via scripts with the same API that the pause button in studio uses, as you can only use it via the command bar or plugin scripts (see RunService:Pause()), forcing you to recreate it.

If you want to recreate the pause system, you’ll just need to anchor the player’s parts, then use :SetCore() to disable the reset button, as well as scripting the camera to move around freely.

That could work. I’ll get to work with that idea in a little while, thanks for the help! I’d rather wait to mark it as a solution so that I can see what other people think.

Following with what GeicoInsurance said,
I would recommend creating a button to pause and programming it to do multiple functions, like anchors the player, and disabling the reset button, and pausing the random number generator.

This does seem really intriguing.

I would set it up like this:
image

and write this code:

local check = script.Parent.Check.Value

script.Parent.MouseButton1Down:Connect(function() -- checks if a button has been clicked by a user
	if check == true then
		--whatever you want to happen here
	else --if check == false then
		--wharever you want to happen here, but I would reverse what you did on top
	end
end)

Hope you have luck with your pause button!
WE

Edit: I would also turn the random number generator into a local part unless you want it to pause for the server.

Edit2: I always forget .Value :sob:I hope to break out of that habit soon!

This could work too! I’ve made a show game textures/hide game textures button before, so I have some experience with that. Thanks for the help, and I forget .Value sometimes too. :sweat_smile:

If you need help, you know where to find me.

Something really weird happened…

The first time I ran the game, I was only testing the disable reset character script I couldn’t reset my character, but the second time, I got this message:

SetCore: ResetButtonCallback has not been registered by the CoreScripts

…The heck? Why did it work the first time but not the second? I’m so confused!!!

That’s because, as the error implies, ResetButtonCallback hasn’t been registered yet. You can fix it by simply wrapping it into a pcall like this:

repeat
	local success = pcall(function()
		game:GetService("StarterGui"):SetCore("ResetButtonCallback", false)
	end)
	wait()
until success

You can try copy and pasting the default freecam script in studio (the one that is activated by ctrl+shift+p) and cloning it into the player from the server when you need it. It’ll make it seem more like you’re actually pausing the game like in studio.

What stumps me is that it worked the 1st time, but not the second. What’s up with that?