I am trying to create a quest system, but I have never used modules with a systemic approach. As can be seen, quest 1 refers to the dictionary before it finishes defining itself, which causes an error. At broad, how can I approach making a quest system in that way that this is intended to work? Since this is my first attempt, I’m sure I’ll make otherwise obvious mistakes, so how should I structure this? Aside from the error, is this format optimal? If not, what is a better way to approach this. Any feedback helps. Thanks!
local Players = game:GetService("Players")
local quests = {
[1] = {
description = "Go to mines",
startQuest = function(player)
workspace.Mine.A1.Touched:Connect(function(hit)
if Players:GetPlayerFromCharacter(hit.Parent) == player then
quests[2].startQuest()
end
end)
end,
},
[2] = {
description = "Mine 6 iron",
startQuest = function(player)
end,
}
}
return quests