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

Is there Anyway To stop an Event or Function without Disabling the script?

I want to Disable the script for a certain time but I don't know anything that can stop it. Can I get some help?

1 answer

✓ Accepted answer

###You can use coroutines.

According to Roblox,

Starts or continues the execution of coroutine co. The first time you resume a coroutine, it starts running its body. The params are passed as the arguments to the body function. If the coroutine has yielded, resume restarts it, and the params are passed as the results from the yield.

#####If the coroutine runs without any errors, resume returns true plus any values passed to yield (if the coroutine yields) or any values returned by the body function (if the coroutine terminates). If there is any error, resume returns false plus the error message.

Example:

local function f(a, b, c)
    print(a, b, c)
end
 
thread = coroutine.create(f) 
coroutine.resume(thread, 1, 2, 3) 

###For your case, you'd probably want to do:

local thread = coroutine.create(function()
	-- maybe some code before you yield
	coroutine.yield()
	-- code where you want to pause 
end)
 
coroutine.resume(thread) -- start running the code 
wait(5) -- time to wait, 
coroutine.resume(thread) -- this will make it stop yielding 

1 comment

0

Thanks

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