Is it possible for tick() to be called at the exact same time?

I’m currently working on a data saving system for my game, and using keys based off of tick() (Sounds weird but it is needed for my use.)

Would it be possible for tick() to be called at the exact same time (maybe from another server), and have 2 datas with the same key?

If so, is there anyway to prevent this from happening?

1 Like

Very unlikely but there’s a tiny chance. How about adding a global (server-replicated) debounce, so if data with the same key exists just do a wait() and tick again?

Yes it is possible, also tick will be different depending on the time-zone of the server that it’s called from. If you’re using it to tell time you should probably use os.time instead because it’s the same no matter where the server is.

Read what I said, I’m using it for a key in my datastore

Yes, but, if tick() is called at the same time across 2 different servers, then both check if that key already exists at the same time, then they’re both going to say that it doesnt exist

I guess you could check if a datastore with that key exists already and if it does just get another tick

I can further explain what I’m using this for if it helps

Read what I responded to rad with

does the time matter or are you just trying to generate a completely new random key each time?

Time doesn’t matter, I’m just trying to get a completely new key for each thing

you could use another method like doing (os.time() … os.clock()) I don’t think you’d ever get an overlap that way

That wouldnt make a difference, because if a script within 2 servers are checking at the exact same time they would still return the same thing. That would just make a longer number

Actually, I think I have a solution. Seen as how there’s a delay behind setting data in my use, I’ll just include the player UserId after the tick, then find a way to seperate the tick and userId when I need it

This ended up being my solution. I used string.split to achieve this

image

Hm… wonder where I know the person who responded :thinking:

Thank you! :grinning_face_with_smiling_eyes:

1 Like