I have a questModule in my game with like 30 different quests. How do i make so that the quests reset every certain amount of time. Like every 24 hours or 48 hours. And my idea was that 6 random quests will be picked from the questmodule every time the quests reset but how do i make sure everyplayer gets those same 6 random quests?
Just clear a ActiveQuests key in player database after your desired time and assign new ones and save to datastore. Don’t overcomplicate things. (Assign quests on server)
Hello, to make sure every player always gets the same 6 quests that reset every 24 or 48 hours, you can store the reset information in a DataStore. That DataStore will contain two values: the time of the last reset and the list of the current 6 quests.
When a player joins, you load that DataStore:
=> If less than 24 hours have passed since the last reset, you give them the saved quests.
=> If 24 hours or more have passed, you roll 6 new random quests, save them together with the new reset time in the DataStore, and then give players those new quests
sorry i havent used datastores in a while (i use profile service) and i’ve only used it to store player data. How do i just store it to the server or the game itself?
DataStores save data to the game by default
Save their quest inside of a datastore with an expiry timestamp.
Use os.time() to get the current amount of seconds that have passed since January 1st 1970.
Here’s a bit of code to help me explain it a little better.
local expires = os.time() + 6*60^2 -- 6 hours in seconds
-- Check this whenever it is relevant
if os.time() > expires then
print("Quest has expired")
-- Give the player a new quest
end