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

How do you pause a script without making it start over again?

For example Doing: Game.Workspace.Brick.Script.Disabled = true, will just make it start over. I want to know how to pause the script.

3 comments

0

corountines maybe

0

just add a while true do and break it when you want to resume it lmao, simple solution.

0

No its way more complicated than that, I will run into more problems if i follow that advice

2 answers

✓ Accepted answer

little example on how you can stop and start a script without disabling it.

--// this creates a bool Value in the workspace so you can see it working, Just look for a Go Bool Value in your workspace!
local DoGo = (function()
	local D = workspace:FindFirstChild("Go")
	if(D == nil) then
		D = Instance.new("BoolValue",workspace)
		D.Name = "Go"
	end
	return D
end)()

-- Simple timers to show how long we're either running for or waiting for... These are not needed to do this. Its just a fancy way to show it working!.
-- Grab our starting tick via tick()
local StartTime = tick()
local WaitTime = tick()

-- main Loop
while true do
	if(DoGo.Value == true) then -- if our Go value is true then start everything
		local NowTime = math.floor(tick() - StartTime + 0.5)
		print("Woo!, We're been computing since [",NowTime,"] Secs!")
		WaitTime = tick()
	else -- our go value is false lets wait!...
		local MyWaitTime = math.floor(tick() - WaitTime +0.5)
		StartTime = tick()
		print("Waiting ", MyWaitTime , "Secs!")
	end
	wait()
end

hope this helps! :)

2 comments

0

Thank you! you are amazing, with this step out of the way

0

I can now make the game of my dreams

Just do event:Wait() and the event is anything you want like a bindable event or something

6 comments

0

Script.Event:Wait() ?

0

No, :Wait() does not continue with code until the event is fired. An event is anything that you can use :Connect(function() with. It will continue with the script once the event is fired.

0

Where should I insert the event?

0

I'm new to events

0

Like this?: script.Parent.Parent.Event:Wait()

0

I made a bindable event and its child is the script

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