How to use return in loop without breaking it

So I need to use return in a loop without breaking it and idk how to

1 Like

Well, that’s impossible. Returning in a loop will stop the loop from running, and return the result to whatever it is requested it. Why do you want to do such a thing?

You could set a variable and then return the variable once the loop has finished, but you cannot return mid-iteration without breaking it.


Ok well got it, so I basically can just use variable to do so

Glad I could help. Make sure to mark this topic as solved so it can close if you have no further issues.

btw, do you know how to check if server still exists with its Job Id or anything other

1 Like

If no players exist in a server, it will shut down with a maximum of 30s after no players are left (if BindToClose code has been added).

1 Like

uh, I mean, I store server job id in datastore because I need that to 1 server choose summons in my game, but what if server fails to update data to datastore when its closing, then it will lead to never updating summons

1 Like

Why would you rely on one server?

This sounds like quite a complicated issue, you should probably make a new topic and provide more information so me and other people can help better.

I already did and someone sent script that uses message service
but it stores only one server in the “message” (?) and it will not work as I want

I need that because then when summon changes, it will change again when it shouldn’t (because other server have choosen too)

Maybe something like MemoryStoreService would be better. However, this is completely unrelated to this topic and is now off-topic; create a new topic or bump your old one.

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