So for a while I’ve been thinking about making some kind of daily objectives stuff to keep the player engaged, and then I came to the realization that any kind of system like that would probably be super inefficient. Here’s what I mean
Let’s assume the player has say, 2 quests. Quest A is “Assist someone 5 times” and Quest B is “Get 10 headshots”. Then there’s the issue of how I would get these functions to update on the player’s progress every time they perform one of these tasks.
Here’s what I thought of so far:
Would I have some kind of universal BindableEvent for quests?
Perhaps functions inside of a ModuleScript that fire when something happens?
Individually make functions for each quest? (although that would be highly inefficient)
TL;DR, I don’t know how I could approach this and I’m wondering if you guys have any ideas on how I can do this, and no I’m not asking for scripts, just ideas.
Just save each of the items you want to check for the quests to a Datastore. Wherever a player did the action, update the Datastore, and check if they reached the quest threshold. If you want it to reset each day, just save to the Datastore the time they first joined your game, and check if it’s been 24 hours since then, and reset all the items in it to 0, and save the new time.
There’s a bunch of other stuff that goes into this, but this is just a basic run down.
Yes but my question is how I would check if these things updated. I can’t just go making an update function for each individual function, that’d be tedious and inefficient!
I’d recommend making a table in the code that’s a mirror of the Datastore info for each player in the server currently, and updating that as well as the Datastore. Then, using run service, check that table every frame rather than the actual Datastore, since you’d quickly reach the get async limit.
runservice and datastores would not be helpful here at all
The easiest way I can think of is to use a modulescript to keep track of quests and progress. You can have a quest object with some basic info like name/id, player it is assigned to, and progress. Each time the player does an action that is a part of the quest, increment the progress of that quest if the player has it
Perhaps you could make a custom lua event system. For each player, you could make one event object for headshots, one for assists, etc. Then in the function where headshots are detected, fire the event for headshots. When the player gets a headshot quest, connect a function to the headshot event. When the they have got the correct amount of headshots, disconnect the connection.
The event system could even be used for more than just quests. For example, if you wanted a visual effect to happen when the player gets a headshot, you wouldn’t need to handle that in the function that detects the headshots. You could instead make a handler function for it elsewhere and connect it to the headshot event.
Edit: I also agree with @0Luke_Skywalker0 about using quest objects.
How would that data persist across sessions without Datastores it’s supposed to last all day. Using a module script is a good idea for sure but he’d definitely need DataStore Service. And you didn’t really answer his question. He asked
That’s why I recommended run service. Either use an event that fires a function every time the action is taken, or use run service, check if the action has been taken, and fire the function.
Don’t take this as an attack, but as my defending my answer after it got invalidated.
Runservice would be very inefficient since that means you have to check every frame, usually 60 times a second, which will increase activity by some unholy amounts.
Yes, using an event would be much better than runservice
While I agree that Datastores are probably needed, he never mentioned it specifically and only asked for a quest progression system, but yea he needs it if the quests need to save