Note: This problem has, rather, evolved into a different one and has been narrowed down. When you see the periods next to the word “skip” you can skip to the rest of the thread.
… start here …
I’m adding quests to my game. It’s a lot of code so I’ll just give some background info on it:
- There are three dictionaries: One handles the messages the player sees; one handles the maximum values needed for each quest (e.g. in a phrase like “win the game 3 times”, the value would be 3); and the last one handles what the rewards are, as they are arbitrary numbers and are not meant to be calculated by an algorithm.
- The player has values like
QuestProgressand some others that are basically just there so that they can be referenced and utilized throughout the game.
- When all the necessary data has been collected, a RemoteEvent is fired to the client to show them all the necessary information.
The last thing I should add to this description is that I have a script called
RoundHandler. It basically uses a
while true do loop since I have a round-based game, and it handles all the stuff, e.g. teleporting players and all the other stuff.
… skip …
I haven’t had many issues with it… until today. One of my quests is called “Play 3 rounds”. So what I did is I added a value to the player called PlayedThisRound, and basically if the player is not nil, has been teleported to the game, and is not marked as AFK, it will mark
PlayedThisRound.Value to true. Otherwise it stays false. At the end of each round, if
PlayedThisRound.Value == true then I run the following code:
QuestProgress.Value = QuestProgress.Value + 1. I know this is a lot of information to take in, so I also copied + pasted a piece of my script in the
RoundHandler script, which is in
for _, player in ipairs(game.Players:GetPlayers()) do if player.PlayedThisRound.Value == true then player.TimesPlayed.Value = player.TimesPlayed.Value + 1 if player.QuestNum.Value == 1 then player.QuestProgress.Value = player.QuestProgress.Value + 1 wait() end end player.PlayedThisRound.Value = false wait() end
I have tried removing the first
wait() statement but all it did was make the value not increment at all, and obviously that would be changing the issue instead of fixing it. It generally increments by 10, so after completing a single round I’ll see that the progress bar says 10 / 3. Of course it’s supposed to say 1 / 3. I know it’s not a client issue because I have played the rounds and checked the
QuestProgress value, and it reflects the same values the client-side is showing.
I have had this issue take many forms before, and unfortunately none have been fixed. This time it’s more prominent and I feel like it would really defeat the purpose of quests if they could be completed in one go. Please help, I really want to continue working on quests but this has been really problematic. All advice will be appreciated!