Suppose I needed to run some code on both the client and server (different code for each) whenever a player’s character respawned. I also needed the client code to wait for the server code to finish running first and/or to fetch some information from it, so to simplify my code I decided to go like this:
In the server, run code when CharacterAdded fires, then fire a remote event
The client waits for the server to fire the remote event rather than using CharacterAdded
The question is, is the remote event signal guaranteed to arrive the client after the new character has replicated (as if I used CharacterAdded), even if the server code doesn’t yield before firing the event?
Edit: To make what I meant to ask more clear: will the signal always arrive after the character was replicated or can it arrive while the client still sees the previous character? I know it is guaranteed to arrive at some point.
I think either you misunderstood my question or I misunderstood your answer.
What I meant is, will the signal always arrive after the character was replicated or can it arrive while the client still sees the previous character?
After some testing, it seems like my idea doesn’t work well…
Using LocalPlayer.Character in the remote event callback and attempting to do something like destroying a limb has no effect so it’s probably referring to the old character. Passing the new character results in nil in the client likely because CharacterAdded fires before the character is parented to DataModel, so it seems to me CharacterAdded fires in the server before the character is replicated to the client.