Why don’t you try using remote events or remote functions? If you’re wanting cross communication between server - server boundary then you should use bindable events or bindable functions.
If you’re wanting to enable/disable an active script, I assume that it involves code that is constantly active. To do this, there’s no need to have code in separate scripts unless it’s for organization. You can simply use the task library to achieve full control on the running of your code.
If you pass a function to task.spawn() it will run the passed function in a new thread, and return the newly active thread (known as a coroutine).
By storing access to that thread in a variable, you can cancel it whenever you want with task.cancel(). By passing an active thread to this function, it immediately stops further execution of the thread on the task scheduler.
Here’s what it might look like set up:
local function ThreeLetters()
print('A')
task.wait(1.5)
print('B')
task.wait(1)
print('C')
end
local New_Thread = task.spawn(ThreeLetters) --Runs ThreeLetters in a new thread. Does not yield.
task.wait(2) --Wait 2.5 seconds into ThreeLetters.
task.cancel(New_Thread) --Cancels the execution of the running thread for ThreeLetters returned by task.spawn
--A and B should print, but the function should be canceled before getting to C.
Can you be a little more specific with your exact goal you are trying to achieve? You should never disable/enable scripts during run time.
Based on what I gather, you can have a single script in ServerScriptService to manage all these models that you are cloning to the workspace, rather than having a copy of the script for each model you clone.
Ok so for my goal, I’m trying to prevent a script from running (initially put into ServerStorage) until a server script clones it and puts it into workspace. The thing is that when a client script clones and puts the script into workspace, it returns an Infinite yield warning as the server script provides one of the variables required for that script to run
It would be hard to put the script as a single script in ServerScriptService as my existing code is very messy and limiting, making it quite difficult to put stuff without making major adjustments to the code, which takes time