SetAsync is slow mostly

  1. What do you want to achieve? Keep it simple and clear!
    Be able to save when a player leaves

  2. What is the issue?
    When a player leaves the setasync line is NOT playing unless I do it with a button manually

  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I tried changing to UpdateAsync although I know it’s slower, but it does not even work on it. And as said setasync works only manually so I assume the player leaves too fast.
    I have put a print line before and after the setasync and only the line that is before setasync is being run and it does not go further.

1 Like

Based on your brief description, this sounds more like an issue with your method of implementation itself than the function yielding, especially considering you mentioned the line isn’t executing at all, there may be reachability issues that may be overlooked and directed towards correction if you posted your code for further assistance.

Maybe, but when I do with manually while the player is still in the game it works all the time while when leaving it only works sometimes. So I’m not sure if it really is the implenetation

I’m unsure of what sort of help are you expecting from the community based on a brief textual description of the issue without providing any code and context to point anyone attempting to help you in the right direction.

For anyone attempting to help, there’s nothing to go off of other than blindly darting at countless reasons this might be occurring due to. I’d definitely suggest thoroughly reading through the category’s pinned post to make sure your posts contain all required information in order to receive any help at all.

1 Like

If you’re talking about the scripting support places and the category, then I’m not sure what to else to put it to and actually get help.

No, I’m not pointing about your post being in the wrong category, you’re in-fact at the correct place. I’m pointing at the fact that you’re providing almost no necessary information needed to receive help regarding your matter, which is mainly your code. Without seeing what you’re doing, you cannot expect people to blindly list an array of hundreds of potential reasons your issue might be occurring. Post what you’ve done so far in an attempt to fix this issue, how is it caused, and what your code looks like.

This is probably because the user leaving is the last person in the server, and the server has started to shut down before it gets to save the data. You can use game:BindToClose() to ensure all user data is saved before the last player leaves. If you dont want to add logic to ensure user data is saved, you could take the lazy route and just delay closing by a few seconds:

game:BindToClose(function()
   wait(10)
end)

However, you should add logic to save all user data in the server when that function is called, so if Roblox shuts your server down, you can quickly save the data. It should also be noted that Roblox will quit the function if it takes more than 30 seconds to complete.

1 Like

Im kinda not comfortable giving it out here, but what I can say is that all I’m saving is a single table with basic info about a single part, so I’m not sure how you want to see it.

True it helped, I did not know I was gonna be needing it now since I never had this issue before, and yes there was only 1 player too.

I did not mean to come off as argumentative at all, and I apologize if I did.

The solution provided to you was a result of guesswork, probability, assumption, uncertainty that it may be an issue. If it didn’t happen to be the problem, there’d need to be more guesswork involved without any assurance that any of effort put into the solutions by the community will yield a positive result at all, hence my point.

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