How do I manage a client-server load ensuring system like this?

Pseudocode:

Server:

  • Player joins
    • Makes Player profile through DataStore (yielding)
    • Fire LoadComplete RemoteEvent
  • RemoteFunction DataExists returns (Player Profile existing)

loading LocalScript in ReplicatedFirst:

  • if not DataExists:Invoke(DataExists)
    • LoadComplete RemoteEvent:Wait()

Problem is, while the Invoke to the DataExists is yielding the script, LoadComplete can fire any time, and the invoke can return false. That means the Player is stuck at load forever.

How can I not ensure this?

I do NOT want a wait() loop.

2 Likes

One option could be to stop using the LoadComplete RemoteEvent in favor of a RemoteFunction that the client uses ask the server to load the data, and simply returns it to the client when finished.

1 Like