Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

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

Asked by
65E0 11
2 years ago

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

0
corountines maybe echobloxia 21 — 2y
0
just add a while true do and break it when you want to resume it lmao, simple solution. greatneil80 2647 — 2y
0
No its way more complicated than that, I will run into more problems if i follow that advice 65E0 11 — 2y

2 answers

Log in to vote
0
Answered by
TGazza 1336 Moderation Voter
2 years ago

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! :)

0
Thank you! you are amazing, with this step out of the way 65E0 11 — 2y
0
I can now make the game of my dreams 65E0 11 — 2y
Ad
Log in to vote
0
Answered by 2 years ago

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

0
Script.Event:Wait() ? 65E0 11 — 2y
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. AnimeAdiction2 0 — 2y
0
Where should I insert the event? 65E0 11 — 2y
0
I'm new to events 65E0 11 — 2y
View all comments (2 more)
0
Like this?: script.Parent.Parent.Event:Wait() 65E0 11 — 2y
0
I made a bindable event and its child is the script 65E0 11 — 2y

Answer this question