Server Script runs after Local Script

Hello guys, so currently, I’m working to test out FireServer() to work with animating tools and stuffs.
But then I encounter an issue : The Sever Script runs after Local Script

So the problem is shown in the image below, you can see I used FireServer to tell the Server Script to work.
image
– Local Script –

But unfortunately, the script doesn’t work. At first, I though it was just because of I did it wrong somewhere, until I decided to print Children in both Local Script and Sever Script. Surprisingly, the Server Script runs after the Local Script although it’s told to be run first


– Server Script –
Here is the output :
image

So I’m looking for solutions, I appreciate if I can get any of help from you guys!

Do you mean that when you call FireServer on the client, the client prints before the server does? FireServer is not blocking, so the LocalScript isn’t waiting for the server to get the message. The client sends FireServer and then prints. The server needs to wait for the FireServer event to be sent over the network, and then it has several additional lines of code before it gets around to printing.

If you need to wait for the server to finish, you should switch your RemoteEvent to a RemoteFunction.

1 Like

Yes, that is expected behavior. The server (listening for a FireServer event) will run after it has been called to by the client.

2 Likes

This is expected behavior. I advise you to check out the client-server model and how RemoteEvents & RemoteFunctions work. And what is your goal here?

1 Like

I didn’t know about it
And my problem is fixed, thank you so much !!

1 Like

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