Whats the best way to connect 2 scripts?

I am trying to connect 2 server scripts together, so when one script is finished, the other one runs. I want to do this for organization reasons, and i don’t know what the best way to do it is.

1 Like

You could use BindableEvents, keep in mind that these can not cross over the server-client boundary. If you fire the event on the server, you need to have it connected on the server, the same with the client. Just fire the event when all other code is done, which would need to be decided by you.

2 Likes

You could put a function A in a ModuleScript, function B in a module script, and call them both in a server Script:

--- module A
return function DoSomethingFirst()
  print("something")
end
-- module B
return function DoSomethingSecond()
  print("something else")
end
-- server script that ties them together
local DoSomethingFirst = require(game.ReplicatedStorage.ModuleA)
local DoSomethingSecond = require(game.ReplicatedStorage.ModuleB)

DoSomethingFirst()
DoSomethingSecond()
1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.