Hi!
I am building a script to help me control all of my games via an external server. All of that is going smoothly, but I have run into a single problem.
Say I required a script somewhere in the code:
local module = require(...)
Later in the code, if I want this script to stop executing, how can I disable it?
module:Disable() -- How would I do this?
Keep in mind that I am requiring the script through an AssetID, not a module script instance in the game.
Thank you in advance, Bloxlin
xZylter
(xZylter)
December 26, 2022, 5:59pm
#2
Not enough information to provide a clear answer.
Ok how about this.
Say in a modulescript, I have the following code:
local module = {}
-- Prints Hello World every second
while wait(1) do
print('Hello world')
end
return module
If you were to require this module via another script,
local module = require(...)
it would print “Hello world” every second.
How could I “Disable” this script so that it stops printing “Hello world”
Could you wrap it in a task and then cancel that task
1 Like
xZylter
(xZylter)
December 26, 2022, 6:06pm
#5
Wouldn’t recommend throwing a while loop in a module script, it just makes the whole module script being used for that task. There must be a better way to handle whatever code you’re doing.
The reason I am not actually taking advantage of the module is because I need to require it by the asset ID to execute whatever I need to happen.
That will add some complications, but I do believe that will work! Can’t believe I didn’t think of that
1 Like
system
(system)
Closed
January 9, 2023, 6:09pm
#8
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.