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

What is the command that will make Script A run Script B and C simultaneously?

Asked by 6 years ago

Hey, I want to run a script that already exists by running a script. What I'm looking for is a command that I can enter in a Script A that will make Script B and C run simultaneously. Thanks

3 answers

Log in to vote
0
Answered by 6 years ago

There are easier ways to do it, but you can activate a remote event in script A and make a function in B and C that activates when the remote event is fired.

Ad
Log in to vote
0
Answered by
Nonaz_jr 439 Moderation Voter
6 years ago

Scripts cannot really run 'Simultaneously', the CPU will only do portions of each at a time.

However, to activate them at the same time so that they run (potentially in a random order) around the same time, (for example while loops) just set disabled=false for both.

script1.Disabled = false
script2.Disabled = false

(and disable them beforehand)

I'm not sure but it sounds to me you may be trying to do something you should not be doing. Don't let independent scripts depend to much on their exact relative timing of executions, if possible.

for example if u always need to do A, then B, then A, then B etc, then don't write a script with timed loops that does A and another that does B, make it one script. If anything to save you from torture during bugfixing!

Log in to vote
0
Answered by 6 years ago

A hackish way would be to clone the script from ServerStorage into ServerScriptService:

Main Script:

print("Start running")

spawn(function()
    local script1 = game.ServerStorage:FindFirstChild("Script1"):Clone()
    script1.Parent = game.ServerScriptService
end)

spawn(function()
    local script2 = game.ServerStorage:FindFirstChild("Script2"):Clone()
    script2.Parent = game.ServerScriptService
end)

In Script1:

print("I am running")

In Script2:

print("I am running 2")

Answer this question