Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How can you pause and resume a script?

I have a script running a dialogue and if the player presses a key, a pause menu opens. I want to pause the script when the player enters the pause menu and resume when the play exits the pause menu.

Is there any way you can pause and resume a script?

1 comment

0

Why not use a function to enable/disable instead

1 answer

Use the Disabled property in a script. For example:

-- Pause
script.Disabled = true 

-- Resume
script.Disabled = false

You'd need to do the resume part in another script though.

4 comments

0

Disabling scripts at runtime is dumb and bad. It can cause unexpected issues cuz ur scripts wont know what disabled it, so take my invisible downvote

0

Then how would you pause it?

0

By using bindableevents along with variables

0

Or just create a coroutine and use coroutine.resume to start it and resume it again and use coroutine.yield to pause it.

This discussion is preserved as it was. New answers, comments, and votes are closed.