How to get serverscript to run multiple threads per player

I am working on a game that needs this, as i can not run the code from a local script because it just breaks for seemingly no reason, so I made several changes for it to be able to run as a server script. The thing is, since i need to be able to run multiple threads without using spawn(), how could i achieve this with coroutines or any other method?

(Btw I can’t use spawn because the script works with a remoteFunction so a return is necessary, so i’m not sure if using spawn prevents the wait for the return from happening.)

If you are set function as OnServerInvoke then script is already runs in separated thread. However, could you be more specific about what you are trying to make and how you are trying to make it, including code blocks would help a lot.


I was making a gui based battle system for a game, i had to use a server script because otherwise the bit of OOP i used messed up.

Actually it doesnt give me any hint about the issue. Anyway seem it works like you want to? If you are not sure about something then you could try to test it in empty place or command bar to make sure how it works.

1 Like

Yes, i did not know remotefnctions worked that way, this does solve my query.

For future reference, its actually the same for any event I believe.

Edit: Should probably clarify for others as well, that “multiple threads” is not the same as “multi threading”. The first “cleverly swaps” threads and runs them in succession where the latter runs more than 1 thread at a time. I don’t believe Roblox supports “multi threading”.

1 Like