Planning out a system for quests

Hi, I’m here trying to make a quest system for my game, however I need to devise a plan on how to make such a mechanism work.

What I desire
In my game, there are towns have GUIs respectively when clicked, and a random quest will pop up in the GUI and when someone clicks to take the quest, the GUI disappears except for the player who took the quest.

How many remote events and scripts will I be needing for such a thing?

What I have
I’ve actually made one prior to this but found out that it’s very client based

  • ServerScript randomly fires event to all clients
  • All clients receive the quest via localscriptA
  • If a user clicks the quest, another event is fired via localscriptB
  • A serverscript receives the serverfire() and fires towards localscriptA
  • localscriptA shuts down the quest…

And hence my issue, it’s not on the server, so new players who joined the server can’t see the old quests if its not completed!
Can anyone help me on this issue? I’m still new to scripting and I’d love to challenge myself with these kind of things!

1 Like

I still don’t fully understand so my bad if this is not what you’re looking for, however:

The way i would structure it, is a little something like this:

  • Have a ModuleScript within a Script in serverscriptservice
    or

  • Have a table within the one script in serverscriptservice

  • Inside of the modulescript / table, Structure it like this:

Table = {
Town1 = {--List of quests here},
Town2 = {--List of quests here}
}
  • When you need a client to get a quest, require it from the server via remotevents, E.g When
    a player joins, You will want to fire a remotevent (from the client) then the script will
    pick out a random quest then fire the player’s client with the quest.

Let me know if i’ve misunderstood you.

3 Likes

Well, I understood what you said, but doesn’t you way still make newplayers unable to see pre existing quests?

Let’s say I had been in the server for 5 minutes, and a remoteevent was fired that allowed me to see the quest. If we used a FireAllClients(), wouldn’t new players unable to see the quest that was fired 5 minutes ago?

I’ve been playing around with client/server tests on RBLX studio, and if users join on a later time, they can’t see the quests that are active for older users in the server.

To be honest, now I think about it, fixing my current script to let the GUI appear on StarterGui (not PlayerGui) and then refreshing all Clients screen via a script probably what I need. Does anyone how to do this?

If you want for players to be able to see pre-existing quests, you will need to store quests in a table as you go.

Say a new quest pops up then 5 mins later another one, you will need to store them both in a table.

I don’t think you need to do this, if you’re requiring quests from the server etc. It is best to disable ResetOnSpawn for the ScreenGui so that way, the UI doesn’t reset it’s contents and you can constantly fetch / edit data from the server

1 Like

Could you elaborate more about this? Trying to think on applying what you said, but struggling mostly on how to make it both visible for client and server. I’m sorry but sadly tables is one of the parts in coding where I seem to struggle a lot q.q

Basically what i am trying to say is, You have a serverscript.

You’ve the table in it mentioned from before:

Quests = {
Town1 = {--List of quests here},
Town2 = {--List of quests here}
}

Then ontop of that, You have a Table that contains a log of all the quests that have been chosen so far.

TableLog = {}

Now, whenever the server choses a random quest from the “Quests” table, it will insert it into the “TableLog” Table and then will fire all clients containing the TableLog

local QuestRemoteEvent = game.ReplicatedStorage.QuestRemoteEvent

local Quests = {
Town1 = {--List of quests here},
Town2 = {--List of quests here}
}

local TableLog = {}

function ChoseQuest()
table.insert(TableLog, ChosenQuest)

return TableLog
--This function will chose a quest then return it
end

QuestRemoteEvent:FireAllClients(ChosenQuest())

while wait(300) do --Every 5 minutes
QuestRemoteEvent:FireAllClients(ChosenQuest())
end

The function will add the quest to the log and then will send that off to the client.

This is a very rough interpretation, you will need to alter it to match your needs

1 Like

Assuming from this, if the RemoteEvent was fired a minute ago and I just joined the game, I’ll need to wait 4 minutes until the previous quest (if it wasn’t finished) is visible to me?

Yes, but that can be fixed with a playeradded event

game.Players.PlayerAdded:Connect(function(plr)
QuestRemotEvent:FireClients(plr, ChosenQuest())
end

1 Like

Ahh, it all makes sense now, thank you!