I’m trying to make a daily and weekly quest system that resets every 24 hours for the daily quests and resets every 7 days for the weekly quests and have the part where it gets a total of 6 random quests from a dictionary and adds them to a table. I have no idea where to go from here really and don’t know how os.time works.
What I have so far:
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local QuestsDaily = require(ReplicatedStorage.Databases.QuestsDaily)
local dailyQuestsTable = {}
local categorys = {"Power Quests", "Punching Quests", "Gathering Quests"}
while #dailyQuestsTable < 6 do
local category = categorys[math.random(1, #categorys)]
local quest = QuestsDaily[category][math.random(1, #QuestsDaily[category])]
if not table.find(dailyQuestsTable, quest) then
table.insert(dailyQuestsTable, quest)
end
end
print(dailyQuestsTable)
The players quest GUI:
The quests dictionary in a ModuleScript:
local QuestsDaily = {
["Power Quests"] = {
{
Name = "Daily Training I",
Description = "Gain 1M Power",
PowerNeeded = 1000000,
Rewards = {
{
rewardType = "Tokens",
value = 50,
}
}
},
{
Name = "Daily Training II",
Description = "Gain 1B Power",
PowerNeeded = 1000000000,
Rewards = {
{
rewardType = "Tokens",
value = 50,
}
}
},
{
Name = "Daily Training III",
Description = "Gain 1T Power",
PowerNeeded = 1000000000000,
Rewards = {
{
rewardType = "Tokens",
value = 50,
}
}
},
{
Name = "Daily Training IIII",
Description = "Gain 1Q Power",
PowerNeeded = 1000000000000000,
Rewards = {
{
rewardType = "Tokens",
value = 50,
}
}
},
},
["Punching Quests"] = {
{
Name = "Daily Punching I",
Description = "Punch 100 Times",
PunchesNeeded = 100,
Rewards = {
{
rewardType = "Tokens",
value = 50,
}
}
},
{
Name = "Daily Punching II",
Description = "Punch 250 Times",
PunchesNeeded = 250,
Rewards = {
{
rewardType = "Tokens",
value = 50,
}
}
},
{
Name = "Daily Punching III",
Description = "Punch 750 Times",
PunchesNeeded = 750,
Rewards = {
{
rewardType = "Tokens",
value = 50,
}
}
},
{
Name = "Daily Punching IIII",
Description = "Punch 1,500 Times",
PunchesNeeded = 1500,
Rewards = {
{
rewardType = "Tokens",
value = 50,
}
}
},
},
["Gathering Quests"] = {
{
Name = "Daily Gathering I",
Description = "Collect 50 Orbs",
OrbsNeeded = 50,
Rewards = {
{
rewardType = "Tokens",
value = 50,
}
}
},
{
Name = "Daily Gathering II",
Description = "Collect 150 Orbs",
OrbsNeeded = 150,
Rewards = {
{
rewardType = "Tokens",
value = 50,
}
}
},
{
Name = "Daily Gathering III",
Description = "Collect 350 Orbs",
OrbsNeeded = 350,
Rewards = {
{
rewardType = "Tokens",
value = 50,
}
}
},
{
Name = "Daily Gathering IIII",
Description = "Collect 550 Orbs",
OrbsNeeded = 550,
Rewards = {
{
rewardType = "Tokens",
value = 50,
}
}
},
},
}
return QuestsDaily