How to delete player data after a while

Hey this will be an intresting topic.

I need to make it so It auto-deletes a players data in a datastore after some period of time. Is it possible to do that? I don’t want to rely on Server Scripts as the server may close and cause it to reset.

What is the exact purpose of this system?

Sort of a cooldown system, It logs whenever a play uses a thing and it keeps it stored for a while, after that it would delete the data. But I don’t know how it can even tell when to delete it

Do you want it after a certain real time or play time? In the former case, you can save the unix time of whenever it was used, then keep checking if the difference between the current and the usage time is above a certain threshold, then delete it from the data store. The latter is a bit more complicated.

What you can do is save the time which they got the item (using os.time()) and then every so often check

local cooldownTime = 86400 -- Time in seconds until deletion from start, this is one day
if os.time() < os.time() - cooldownTime then
    -- DELETE THE THING
end