Do something after starter scripts have finished running

Hello!

In my game I need the client to inform the server that it is loaded (using a remoteEvent), and i need the starter scripts to be finished because of listener setup.

But I can’t find a way to be 100% sure that all the starter scripts are finished loaded, I tried looking at the order of resources replication but there doesn’t seem to be a way to know when a script is over running.

Simplest way I could think of without adding any more events and whatnot is to just initially call the event from the starter script with a certain keyword, like “START”. Then, at the end, call it again with another keyword, like “END”. The server will know the client has loaded when there are as many “END” events as there are “START” events. Make sure to wait a second or two before assuming the client is fully loaded, just in case.

Oh, I see. But if I have 5 scripts in the starter scripts each one would need to say “START” and “END”?

Yes, every starter script should have a “START” at the very top, and “END” where they finish:

local loadingEvent = ...
loadingEvent:FireServer("START")
...
...
...
loadingEvent:FireServer("END")

Just remember this probably isn’t the best method, but this is the easiest way I can think of right now.

1 Like

Ok thanks for the solution, I’ll do it that way!

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