How exactly do you unlock a session lock?

  1. What do you want to achieve? Keep it simple and clear!
    Currently im relying on ProfileService to save important player data. But ive been researching about session locks recently so i can switch from profile to a a custom datastore module.

  2. What is the issue? Include screenshots / videos if possible!

So from my understanding. When you lock a session. You save the games jobid and time(os.time()). But theres my problem. How do i exactly unlock the session? how do i check when a server has finished hadling data?

  1. What solutions have you tried so far? Did you look for solutions on the Developer Hub?

Ive done some research like i said. But most explanations arent that great or are too advanced for me to understand :sweat_smile:

Do i need to compare the save time? or how exactly do i unlock the session after the server is done handling with the player data??

1 Like

Heres a simple rundown for a basic session lock.

Player joins → load and lock their data
Player leaves → save and unlock their data

A simple way to lock and unlock someones data is to have a “Locked” boolean variable in their data somewhere. You may also want to store a “LockDate” variable in there too, which just stores the time the data was locked, (example data.LockDate = os.clock() + 120, this would lock their data for 2 minutes) we do this just incase their data fails to save when they leave the game. So when you try to load their data, check if os.clock() > data.LockDate

Also I see that you said you were using profile service, so if this didn’t help then just try snooping around in their code to see how they did it.

hope this helped

2 Likes

Why os.clock() instead of os.time()?

use os.time() not clock() chars