local QuestManager = {} local CurrencyManager = require(game.ReplicatedStorage.Scripts:WaitForChild("CurrencyManager")) local ds2 = require(game:GetService("ReplicatedStorage").Scripts.DataStore2.MainModule) local makePopupEvent = game.ReplicatedStorage.Events.MakePopup local Configuration = require(game:GetService("ReplicatedStorage").Configuration) local XPManager = require(game:GetService("ReplicatedStorage").Scripts.XPManager) local Quests = { Quest1 = { ["Name"] = "Survive Easy", ["Instantiate"] = function(player) QuestManager.UpdateText(player,"Quest1",0,1) QuestManager.CheckIfCompletedQuest(player,"Quest1",1) end, ["UpdateProgressBar"] = function(state) if state then return 1 else return 0 end end, ["Requirments"] = { Requirment1 = function(player,alivePlayers,map,difficultyValue) if difficultyValue == "Easy" then for i,v in pairs(alivePlayers) do if v == player then QuestManager.UpdateText(player,"Quest1",1,1) return true end end end return false end }, ["Rewards"] = {["Coin"] = 50,["XP"] = 25}, ["RewardPlayer"] = function(player) QuestManager.CompleteQuest(player,"Quest1",1) print(player.Name .. " Completed 'Survive Easy'") player.Quests.Quest1.Value = false CurrencyManager.GiveCoins(player,50) XPManager.GiveXP(player,25) end }, Quest2 = { ["Name"] = "Survive Medium", ["Instantiate"] = function(player) QuestManager.UpdateText(player,"Quest2",0,1) QuestManager.CheckIfCompletedQuest(player,"Quest2",1) end, ["UpdateProgressBar"] = function(state) if state then return 1 else return 0 end end, ["Requirments"] = { Requirment1 = function(player,alivePlayers,map,difficultyValue) if difficultyValue == "Medium" then for i,v in pairs(alivePlayers) do if v == player then QuestManager.UpdateText(player,"Quest2",1,1) return true end end end return false end }, ["Rewards"] = {["Coin"] = 100,["XP"] = 30}, ["RewardPlayer"] = function(player) QuestManager.CompleteQuest(player,"Quest2",1) print(player.Name .. " Completed 'Survive Medium'") player.Quests.Quest2.Value = false CurrencyManager.GiveCoins(player,100) XPManager.GiveXP(player,30) end }, Quest3 = { ["Name"] = "Survive Hard", ["Instantiate"] = function(player) QuestManager.UpdateText(player,"Quest3",0,1) QuestManager.CheckIfCompletedQuest(player,"Quest3",1) end, ["UpdateProgressBar"] = function(state) if state then return 1 else return 0 end end, ["Requirments"] = { Requirment1 = function(player,alivePlayers,map,difficultyValue) if difficultyValue == "Hard" then for i,v in pairs(alivePlayers) do if v == player then QuestManager.UpdateText(player,"Quest3",1,1) return true end end end return false end }, ["Rewards"] = {["Coin"] = 150,["XP"] = 40}, ["RewardPlayer"] = function(player) QuestManager.CompleteQuest(player,"Quest3",1) print(player.Name .. " Completed 'Survive Hard'") player.Quests.Quest3.Value = false CurrencyManager.GiveCoins(player,150) XPManager.GiveXP(player,40) end }, Quest4 = { ["Name"] = "Survive Any Difficulty", ["Instantiate"] = function(player) QuestManager.UpdateText(player,"Quest4",0,1) QuestManager.CheckIfCompletedQuest(player,"Quest4",1) end, ["UpdateProgressBar"] = function(state) if state then return 1 else return 0 end end, ["Requirments"] = { Requirment1 = function(player,alivePlayers,map) for i,v in pairs(alivePlayers) do if v == player then QuestManager.UpdateText(player,"Quest4",1,1) return true end end return false end }, ["Rewards"] = {["Coin"] = 100,["XP"] = 30}, ["RewardPlayer"] = function(player) QuestManager.CompleteQuest(player,"Quest4",1) print(player.Name .. " Completed 'Survive Any Difficulty'") player.Quests.Quest4.Value = false CurrencyManager.GiveCoins(player,100) XPManager.GiveXP(player,30) end }, Quest5 = { ["Name"] = "Survive 5 Times", ["Instantiate"] = function(player) if not ds2("neededSurvivals5",player):Get() then local playerCurrentSurvivals = ds2("survivals",player):Get(0) local playerNeededSurvivals = playerCurrentSurvivals+5 ds2("neededSurvivals5",player):Set(playerNeededSurvivals) end QuestManager.UpdateText(player,"Quest5",5-(ds2("neededSurvivals5",player):Get(0)-ds2("survivals",player):Get(0)),5) QuestManager.CheckIfCompletedQuest(player,"Quest5",5) end , ["UpdateProgressBar"] = function(player) end, ["Requirments"] = { Requirment1 = function(player) QuestManager.UpdateText(player,"Quest5",5-(ds2("neededSurvivals5",player):Get(0)-ds2("survivals",player):Get(0)),5) if ds2("neededSurvivals5",player):Get(0) <= ds2("survivals",player):Get(0) then return true end return false end }, ["Rewards"] = {["Coin"] = 100,["XP"] = 30}, ["RewardPlayer"] = function(player) QuestManager.CompleteQuest(player,"Quest5",5) player.Quests.Quest5.Value = false print(player.Name .. " Completed 'Survive 5 Times'") ds2("neededSurvivals5",player):Set(nil) CurrencyManager.GiveCoins(player,100) XPManager.GiveXP(player,30) end }, Quest6 = { ["Name"] = "Survive 10 Times", ["Instantiate"] = function(player) if not ds2("neededSurvivals10",player):Get() then local playerCurrentSurvivals = ds2("survivals",player):Get(0) local playerNeededSurvivals = playerCurrentSurvivals+10 ds2("neededSurvivals10",player):Set(playerNeededSurvivals) end QuestManager.UpdateText(player,"Quest6",10-(ds2("neededSurvivals10",player):Get(0)-ds2("survivals",player):Get(0)),10) QuestManager.CheckIfCompletedQuest(player,"Quest6",10) end , ["UpdateProgressBar"] = function(player) end, ["Requirments"] = { Requirment1 = function(player) QuestManager.UpdateText(player,"Quest6",10-(ds2("neededSurvivals10",player):Get(0)-ds2("survivals",player):Get(0)),10) if ds2("neededSurvivals10",player):Get(0) <= ds2("survivals",player):Get(0) then return true end return false end }, ["Rewards"] = {["Coin"] = 150,["XP"] = 50}, ["RewardPlayer"] = function(player) QuestManager.CompleteQuest(player,"Quest6",10) player.Quests.Quest6.Value = false print(player.Name .. " Completed 'Survive 10 Times'") ds2("neededSurvivals10",player):Set(nil) CurrencyManager.GiveCoins(player,150) XPManager.GiveXP(player,50) end }, Quest7 = { ["Name"] = "Survive Easy,Medium and Hard", ["Instantiate"] = function(player) if not ds2("survivedEMH",player):Get() then ds2("survivedEMH",player):Set({["Easy"]=false,["Medium"]=false,["Hard"]=false}) end local count = 0 for difficulty,value in pairs(ds2("survivedEMH",player):Get()) do if value then count = count + 1 end end QuestManager.UpdateText(player,"Quest7",count,3) QuestManager.CheckIfCompletedQuest(player,"Quest7",3) end , ["Requirments"] = { Requirment1 = function(player,alivePlayers,map,difficultyValue) for i,v in pairs(alivePlayers) do if v == player then local survivedEMH = ds2("survivedEMH",player):Get() survivedEMH[difficultyValue] = true ds2("survivedEMH",player):Set(survivedEMH) local count = 0 for difficulty,value in pairs(survivedEMH) do if value then count = count + 1 end end QuestManager.UpdateText(player,"Quest7",count,3) if survivedEMH.Easy == true and survivedEMH.Medium == true and survivedEMH.Hard == true then return true end break end end return false end }, ["Rewards"] = {["Coin"] = 150,["XP"] = 50}, ["RewardPlayer"] = function(player) QuestManager.CompleteQuest(player,"Quest7",3) player.Quests.Quest7.Value = false print(player.Name .. " Completed 'Survive Easy,Medium and Hard'") ds2("survivedEMH",player):Set(nil) CurrencyManager.GiveCoins(player,150) XPManager.GiveXP(player,50) end }, Quest8 = { ["Name"] = "Survive Easy,Medium and Hard without dying!", ["Instantiate"] = function(player) if not ds2("survivedEMHW",player):Get() then ds2("survivedEMHW",player):Set({["Easy"]=false,["Medium"]=false,["Hard"]=false}) end local count = 0 for difficulty,value in pairs(ds2("survivedEMHW",player):Get()) do if value then count = count + 1 end end QuestManager.UpdateText(player,"Quest8",count,3) QuestManager.CheckIfCompletedQuest(player,"Quest8",3) end , ["Requirments"] = { Requirment1 = function(player,alivePlayers,deadPlayers,map,difficultyValue) local count = 0 for i,v in pairs(deadPlayers) do if v == player then ds2("survivedEMHW",player):Set({["Easy"]=false,["Medium"]=false,["Hard"]=false}) count = 0 QuestManager.UpdateText(player,"Quest8",0,3) return false end end for i,v in pairs(alivePlayers) do if v == player then local survivedEMHW = ds2("survivedEMHW",player):Get() survivedEMHW[difficultyValue] = true ds2("survivedEMHW",player):Set(survivedEMHW) for difficulty,value in pairs(survivedEMHW) do if value then count = count + 1 end end QuestManager.UpdateText(player,"Quest8",count,3) if survivedEMHW.Easy == true and survivedEMHW.Medium == true and survivedEMHW.Hard == true then return true end break end end return false end }, ["Rewards"] = {["Coin"] = 200,["XP"] = 75}, ["RewardPlayer"] = function(player) QuestManager.CompleteQuest(player,"Quest8",3) player.Quests.Quest8.Value = false print(player.Name .. " Completed 'Survive Easy,Medium and Hard without dying!'") ds2("survivedEMHW",player):Set(nil) CurrencyManager.GiveCoins(player,200) XPManager.GiveXP(player,75) end }, Quest9 = { ["Name"] = "Play For an Hour", ["Instantiate"] = function(player) if not ds2("oneHourCoin",player):Get() then ds2("oneHourCoin",player):Set(0) end QuestManager.UpdateText(player,"Quest9",0,60) QuestManager.CheckIfCompletedQuest(player,"Quest9",60) end , ["Requirments"] = { Requirment1 = function(player) ds2("oneHourCoin",player):Get(0) ds2("oneHourCoin",player):Increment(1) local totalTime = ds2("oneHourCoin",player):Get() QuestManager.UpdateText(player,"Quest9",math.ceil(totalTime/60),60) if totalTime >= 3600 then return true end return false end }, ["Rewards"] = {["Coin"] = 200,["XP"] = 75}, ["RewardPlayer"] = function(player) QuestManager.CompleteQuest(player,"Quest9",60) player.Quests.Quest9.Value = false print(player.Name .. " Completed 'Play for a Hour'") ds2("oneHourCoin",player):Set(nil) CurrencyManager.GiveCoins(player,200) XPManager.GiveXP(player,75) end }, Quest10 = { ["Name"] = "Play For Two Hours", ["Instantiate"] = function(player) if not ds2("twoHourCoin",player):Get() then ds2("twoHourCoin",player):Set(0) end QuestManager.UpdateText(player,"Quest10",0,120) QuestManager.CheckIfCompletedQuest(player,"Quest10",120) end , ["Requirments"] = { Requirment1 = function(player) ds2("twoHourCoin",player):Get(0) ds2("twoHourCoin",player):Increment(1) local totalTime = ds2("twoHourCoin",player):Get() QuestManager.UpdateText(player,"Quest10",math.ceil(totalTime/60),120) if totalTime >= 7200 then return true end return false end }, ["Rewards"] = {["Coin"] = 250,["XP"] = 100}, ["RewardPlayer"] = function(player) QuestManager.CompleteQuest(player,"Quest10",120) player.Quests.Quest10.Value = false print(player.Name .. " Completed 'Play For Two Hours'") ds2("twoHourCoin",player):Set(nil) CurrencyManager.GiveCoins(player,250) XPManager.GiveXP(player,100) end } } local GemQuests = { Quest100 = { ["Name"] = "Play For Two Hours", ["Instantiate"] = function(player) if not ds2("twoHourGem",player):Get() then ds2("twoHourGem",player):Set(0) end QuestManager.UpdateText(player,"Quest100",0,120) QuestManager.CheckIfCompletedQuest(player,"Quest100",120) end , ["Requirments"] = { Requirment1 = function(player) ds2("twoHourGem",player):Get(0) ds2("twoHourGem",player):Increment(1) local totalTime = ds2("twoHourGem",player):Get() QuestManager.UpdateText(player,"Quest100",math.ceil(totalTime/60),120) if totalTime >= 7200 then return true end return false end }, ["Rewards"] = {["Gem"] = 10,["XP"] = 100}, ["RewardPlayer"] = function(player) QuestManager.CompleteQuest(player,"Quest100",120) player.Quests.Quest100.Value = false print(player.Name .. " Completed 'Play For Two Hours'") ds2("twoHourGem",player):Set(nil) CurrencyManager.GiveGems(player,10) XPManager.GiveXP(player,100) end }, Quest101 = { ["Name"] = "Play For an Hour", ["Instantiate"] = function(player) if not ds2("oneHourGem",player):Get() then ds2("oneHourGem",player):Set(0) end QuestManager.UpdateText(player,"Quest101",0,60) QuestManager.CheckIfCompletedQuest(player,"Quest101",60) end , ["Requirments"] = { Requirment1 = function(player) ds2("oneHourGem",player):Get(0) ds2("oneHourGem",player):Increment(1) local totalTime = ds2("oneHourGem",player):Get() QuestManager.UpdateText(player,"Quest101",math.ceil(totalTime/60),60) if totalTime >= 3600 then return true end return false end }, ["Rewards"] = {["Gem"] = 5,["XP"] = 75}, ["RewardPlayer"] = function(player) QuestManager.CompleteQuest(player,"Quest101",60) player.Quests.Quest101.Value = false print(player.Name .. " Completed 'Play For an Hour'") ds2("oneHourGem",player):Set(nil) CurrencyManager.GiveGems(player,5) XPManager.GiveXP(player,75) end }, Quest102 = { ["Name"] = "Survive 10 Times", ["Instantiate"] = function(player) if not ds2("neededSurvivals10Gems",player):Get() then local playerCurrentSurvivals = ds2("survivals",player):Get(0) local playerNeededSurvivals = playerCurrentSurvivals+10 ds2("neededSurvivals10Gems",player):Set(playerNeededSurvivals) end QuestManager.UpdateText(player,"Quest102",10-(ds2("neededSurvivals10Gems",player):Get(0)-ds2("survivals",player):Get(0)),10) QuestManager.CheckIfCompletedQuest(player,"Quest102",10) end , ["UpdateProgressBar"] = function(player) end, ["Requirments"] = { Requirment1 = function(player) QuestManager.UpdateText(player,"Quest102",10-(ds2("neededSurvivals10Gems",player):Get(0)-ds2("survivals",player):Get(0)),10) if ds2("neededSurvivals10Gems",player):Get(0) <= ds2("survivals",player):Get(0) then return true end return false end }, ["Rewards"] = {["Gem"] = 5,["XP"] = 40}, ["RewardPlayer"] = function(player) QuestManager.CompleteQuest(player,"Quest102",10) player.Quests.Quest102.Value = false print(player.Name .. " Completed 'Survive 10 Times'") ds2("neededSurvivals10Gems",player):Set(nil) CurrencyManager.GiveGems(player,5) XPManager.GiveXP(player,40) end }, Quest103 = { ["Name"] = "Survive 25 Times", ["Instantiate"] = function(player) if not ds2("neededSurvivals25Gems",player):Get() then local playerCurrentSurvivals = ds2("survivals",player):Get(0) local playerNeededSurvivals = playerCurrentSurvivals+25 ds2("neededSurvivals25Gems",player):Set(playerNeededSurvivals) end QuestManager.UpdateText(player,"Quest103",25-(ds2("neededSurvivals25Gems",player):Get(0)-ds2("survivals",player):Get(0)),25) QuestManager.CheckIfCompletedQuest(player,"Quest103",25) end , ["UpdateProgressBar"] = function(player) end, ["Requirments"] = { Requirment1 = function(player) QuestManager.UpdateText(player,"Quest103",25-(ds2("neededSurvivals25Gems",player):Get(0)-ds2("survivals",player):Get(0)),25) if ds2("neededSurvivals25Gems",player):Get(0) <= ds2("survivals",player):Get(0) then return true end return false end }, ["Rewards"] = {["Gem"] = 10,["XP"] = 75}, ["RewardPlayer"] = function(player) QuestManager.CompleteQuest(player,"Quest103",25) player.Quests.Quest103.Value = false print(player.Name .. " Completed 'Survive 10 Times'") ds2("neededSurvivals25Gems",player):Set(nil) CurrencyManager.GiveGems(player,10) XPManager.GiveXP(player,75) end }, Quest104 = { ["Name"] = "Survive Hard", ["Instantiate"] = function(player) QuestManager.UpdateText(player,"Quest104",0,1) QuestManager.CheckIfCompletedQuest(player,"Quest104",1) end, ["Requirments"] = { Requirment1 = function(player,alivePlayers,map,difficultyValue) if difficultyValue == "Hard" then for i,v in pairs(alivePlayers) do if v == player then QuestManager.UpdateText(player,"Quest104",1,1) return true end end end return false end }, ["Rewards"] = {["Gem"] = 5,["XP"] = 25}, ["RewardPlayer"] = function(player) QuestManager.CompleteQuest(player,"Quest104",1) print(player.Name .. " Completed 'Survive Hard'") player.Quests.Quest3.Value = false CurrencyManager.GiveGems(player,5) XPManager.GiveXP(player,25) end }, Quest105 = { ["Name"] = "Survive Easy,Medium and Hard", ["Instantiate"] = function(player) if not ds2("survivedEMHGem",player):Get() then ds2("survivedEMHGem",player):Set({["Easy"]=false,["Medium"]=false,["Hard"]=false}) end local count = 0 for difficulty,value in pairs(ds2("survivedEMHGem",player):Get()) do if value then count = count + 1 end end QuestManager.UpdateText(player,"Quest105",count,3) QuestManager.CheckIfCompletedQuest(player,"Quest105",3) end , ["Requirments"] = { Requirment1 = function(player,alivePlayers,map,difficultyValue) for i,v in pairs(alivePlayers) do if v == player then local survivedEMHGem = ds2("survivedEMHGem",player):Get() survivedEMHGem[difficultyValue] = true ds2("survivedEMHGem",player):Set(survivedEMHGem) local count = 0 for difficulty,value in pairs(survivedEMHGem) do if value then count = count + 1 end end QuestManager.UpdateText(player,"Quest105",count,3) if survivedEMHGem.Easy == true and survivedEMHGem.Medium == true and survivedEMHGem.Hard == true then return true end break end end return false end }, ["Rewards"] = {["Gem"] = 5,["XP"] = 50}, ["RewardPlayer"] = function(player) QuestManager.CompleteQuest(player,"Quest105",3) player.Quests.Quest105.Value = false print(player.Name .. " Completed 'Survive Easy,Medium and Hard'") ds2("survivedEMHGem",player):Set(nil) CurrencyManager.GiveGems(player,5) XPManager.GiveXP(player,50) end }, } ds2.Combine(Configuration.GetDatastoreName(),"neededSurvivals5","neededSurvivals10","survivedEMH","survivedEMHW","oneHourCoin" ,"twoHourCoin","playercompletedquests","twoHourGem","oneHourGem","neededSurvivals10Gems","neededSurvivals25Gems","survivedEMHGem") function QuestManager.Setup(player) local questsFolder = Instance.new("Folder",player) questsFolder.Name = "Quests" local Quest1 = Instance.new("BoolValue",questsFolder) Quest1.Name = "Quest1" Quest1.Value = false local Quest2 = Instance.new("BoolValue",questsFolder) Quest2.Name = "Quest2" Quest2.Value = false local Quest3 = Instance.new("BoolValue",questsFolder) Quest3.Name = "Quest3" Quest3.Value = false local Quest4 = Instance.new("BoolValue",questsFolder) Quest4.Name = "Quest4" Quest4.Value = false local Quest5 = Instance.new("BoolValue",questsFolder) Quest5.Name = "Quest5" Quest5.Value = false --Quests.Quest5.Instantiate(player) local Quest6 = Instance.new("BoolValue",questsFolder) Quest6.Name = "Quest6" Quest6.Value = false --Quests.Quest6.Instantiate(player) local Quest7 = Instance.new("BoolValue",questsFolder) Quest7.Name = "Quest7" Quest7.Value = false --Quests.Quest7.Instantiate(player) local Quest8 = Instance.new("BoolValue",questsFolder) Quest8.Name = "Quest8" Quest8.Value = false --Quests.Quest8.Instantiate(player) local Quest9 = Instance.new("BoolValue",questsFolder) Quest9.Name = "Quest9" Quest9.Value = false local Quest10 = Instance.new("BoolValue",questsFolder) Quest10.Name = "Quest10" Quest10.Value = false --Quests.Quest9.Instantiate(player) local Quest100 = Instance.new("BoolValue",questsFolder) Quest100.Name = "Quest100" Quest100.Value = false local Quest101 = Instance.new("BoolValue",questsFolder) Quest101.Name = "Quest101" Quest101.Value = false local Quest102 = Instance.new("BoolValue",questsFolder) Quest102.Name = "Quest102" Quest102.Value = false local Quest103 = Instance.new("BoolValue",questsFolder) Quest103.Name = "Quest103" Quest103.Value = false local Quest104 = Instance.new("BoolValue",questsFolder) Quest104.Name = "Quest104" Quest104.Value = false local Quest105 = Instance.new("BoolValue",questsFolder) Quest105.Name = "Quest105" Quest105.Value = false end function QuestManager.SelectRandomQuests(questScript,player) local questKeys = {} local gemQuestkeys = {} local questSlots = {questScript.Parent.QuestSlot1,questScript.Parent.QuestSlot2,questScript.Parent.QuestSlot3,questScript.Parent.QuestSlot4,questScript.Parent.QuestSlot5,questScript.Parent.QuestSlot6} for quest, _ in pairs(Quests) do table.insert(questKeys, quest) end for gemQuest, _ in pairs(GemQuests) do table.insert(gemQuestkeys,gemQuest) end local selectedQuests = {} for i=1,4 do local randomQuest = questKeys[math.random(#questKeys)] for t,v in pairs(questKeys) do if v == randomQuest then questSlots[i].QuestValue.Value = randomQuest table.insert(selectedQuests,randomQuest) Quests[randomQuest].Instantiate(player) player.Quests[randomQuest].Value = true questSlots[i].CoinImage.CoinAmount.Text = Quests[randomQuest].Rewards.Coin questSlots[i].QuestName.Text = Quests[randomQuest].Name questSlots[i].XpImage.XPAmount.Text = Quests[randomQuest].Rewards.XP table.remove(questKeys,t) break end end end for i=5,6 do local randomQuest = gemQuestkeys[math.random(#gemQuestkeys)] for t,v in pairs(gemQuestkeys) do if v == randomQuest then questSlots[i].QuestValue.Value = randomQuest table.insert(selectedQuests,randomQuest) player.Quests[randomQuest].Value = true GemQuests[randomQuest].Instantiate(player) questSlots[i].CoinImage.CoinAmount.Text = GemQuests[randomQuest].Rewards.Gem questSlots[i].QuestName.Text = GemQuests[randomQuest].Name questSlots[i].XpImage.XPAmount.Text = GemQuests[randomQuest].Rewards.XP table.remove(gemQuestkeys,t) break end end end ds2("playerquests",player):Set(selectedQuests) return selectedQuests end function QuestManager.GetQuests() return Quests, GemQuests end --ds2.Combine(Configuration.GetDatastoreName(),"neededSurvivals5","neededSurvivals10","survivedEMH","survivedEMHW","oneHourCoin" -- ,"twoHourCoin","playercompletedquests","twoHourGem","oneHourGem","neededSurvivals10Gems") function QuestManager.SelectNewQuests(scriptName,player) ds2("neededSurvivals5",player):Set() ds2("neededSurvivals10",player):Set() ds2("survivedEMH",player):Set({["Easy"]=false,["Medium"]=false,["Hard"]=false}) ds2("survivedEMHW",player):Set({["Easy"]=false,["Medium"]=false,["Hard"]=false}) ds2("oneHourCoin",player):Set() ds2("twoHourCoin",player):Set() ds2("playercompletedquests",player):Set() ds2("playerquests",player):Set() ds2("twoHourGem",player):Set() ds2("neededSurvivals10Gems",player):Set() ds2("oneHourGem",player):Set() ds2("neededSurvivals25Gems",player):Set() ds2("survivedEMHGem",player):Set({["Easy"]=false,["Medium"]=false,["Hard"]=false}) for i, quest in pairs(player.Quests:GetChildren()) do quest.Value = false end local playerQuestsGui = player.PlayerGui:WaitForChild("QuestGui").Frame.Quests local questFinishedSlots = {{playerQuestsGui.QuestSlot1Finish,playerQuestsGui.d1Finish},{playerQuestsGui.QuestSlot2Finish,playerQuestsGui.d2Finish},{playerQuestsGui.QuestSlot3Finish,playerQuestsGui.d3Finish}, {playerQuestsGui.QuestSlot4Finish,playerQuestsGui.d4Finish},{playerQuestsGui.QuestSlot5Finish,playerQuestsGui.d5Finish},{playerQuestsGui.QuestSlot6Finish,playerQuestsGui.d6Finish}} for i, questFinishedSlot in pairs(questFinishedSlots) do questFinishedSlot[1].Visible = false questFinishedSlot[2].Visible = false end return QuestManager.SelectRandomQuests(scriptName,player) end function QuestManager.InstantiateQuests(questScript,player) local playerQuests = ds2("playerquests",player):Get() local questSlots = {questScript.Parent.QuestSlot1,questScript.Parent.QuestSlot2,questScript.Parent.QuestSlot3,questScript.Parent.QuestSlot4,questScript.Parent.QuestSlot5,questScript.Parent.QuestSlot6} for i=1,6 do player.Quests[playerQuests[i]].Value = true questSlots[i].QuestValue.Value = playerQuests[i] end for i=1,6 do if Quests[playerQuests[i]] then questSlots[i].CoinImage.CoinAmount.Text = Quests[playerQuests[i]].Rewards.Coin questSlots[i].QuestName.Text = Quests[playerQuests[i]].Name questSlots[i].XpImage.XPAmount.Text = Quests[playerQuests[i]].Rewards.XP Quests[playerQuests[i]].Instantiate(player) elseif GemQuests[playerQuests[i]] then questSlots[i].CoinImage.CoinAmount.Text = GemQuests[playerQuests[i]].Rewards.Gem questSlots[i].QuestName.Text = GemQuests[playerQuests[i]].Name questSlots[i].XpImage.XPAmount.Text = GemQuests[playerQuests[i]].Rewards.XP GemQuests[playerQuests[i]].Instantiate(player) end end end function QuestManager.CheckPlayerQuests(player) if not ds2("playerquests",player):Get() then return false else return true end end function QuestManager.CheckTimeQuests() wait(5) while true do wait(1) for i,player in pairs(game.Players:GetChildren()) do if player:WaitForChild("Quests").Quest9.Value then if Quests.Quest9.Requirments.Requirment1(player) then Quests.Quest9.RewardPlayer(player) end end if player:WaitForChild("Quests").Quest10.Value then if Quests.Quest10.Requirments.Requirment1(player) then Quests.Quest10.RewardPlayer(player) end end if player:WaitForChild("Quests").Quest100.Value then if GemQuests.Quest100.Requirments.Requirment1(player) then GemQuests.Quest100.RewardPlayer(player) end end if player:WaitForChild("Quests").Quest101.Value then if GemQuests.Quest101.Requirments.Requirment1(player) then GemQuests.Quest101.RewardPlayer(player) end end end end end function QuestManager.UpdateText(player,questName,value,desiredValue) local playerQuestsGui = player.PlayerGui:WaitForChild("QuestGui").Frame.Quests local questSlots = {playerQuestsGui.QuestSlot1,playerQuestsGui.QuestSlot2,playerQuestsGui.QuestSlot3,playerQuestsGui.QuestSlot4,playerQuestsGui.QuestSlot5,playerQuestsGui.QuestSlot6} for t,questSlot in pairs(questSlots) do if questSlot.QuestValue.Value == questName then questSlot.QuestProgress.Text = "["..value.."/"..desiredValue .."]" local newValue = 0.582* value/desiredValue if newValue >= 0.582 then newValue = 0.582 elseif newValue < 0 then newValue = 0 end questSlot.Loading.Size = UDim2.new(newValue,0,0.315,0) break end end end function QuestManager.CheckIfCompletedQuest(player,questValue,finishValue) local playerQuestsGui = player.PlayerGui:WaitForChild("QuestGui").Frame.Quests local questSlots = {playerQuestsGui.QuestSlot1,playerQuestsGui.QuestSlot2,playerQuestsGui.QuestSlot3,playerQuestsGui.QuestSlot4,playerQuestsGui.QuestSlot5,playerQuestsGui.QuestSlot6} local questFinishedSlots = {{playerQuestsGui.QuestSlot1Finish,playerQuestsGui.d1Finish},{playerQuestsGui.QuestSlot2Finish,playerQuestsGui.d2Finish},{playerQuestsGui.QuestSlot3Finish,playerQuestsGui.d3Finish}, {playerQuestsGui.QuestSlot4Finish,playerQuestsGui.d4Finish},{playerQuestsGui.QuestSlot5Finish,playerQuestsGui.d5Finish},{playerQuestsGui.QuestSlot6Finish,playerQuestsGui.d6Finish}} local playerCompletedQuests = ds2("playercompletedquests",player):Get({}) if #playerCompletedQuests == 0 then return false end for i,questSlot in pairs(questSlots) do if questSlot:WaitForChild("QuestValue").Value == questValue then for t,completedQuest in pairs(playerCompletedQuests) do if completedQuest == questValue then questSlot:WaitForChild("QuestCompleted").Value = true player:WaitForChild("Quests")[questValue].Value = false questFinishedSlots[i][1].Visible = true questFinishedSlots[i][2].Visible = true QuestManager.UpdateText(player,questValue,finishValue,finishValue) return end end end end end function QuestManager.CompleteQuest(player,questValue,finishValue) local playerQuestsGui = player.PlayerGui:WaitForChild("QuestGui").Frame.Quests local questFinishedSlots = {{playerQuestsGui.QuestSlot1Finish,playerQuestsGui.d1Finish},{playerQuestsGui.QuestSlot2Finish,playerQuestsGui.d2Finish},{playerQuestsGui.QuestSlot3Finish,playerQuestsGui.d3Finish}, {playerQuestsGui.QuestSlot4Finish,playerQuestsGui.d4Finish},{playerQuestsGui.QuestSlot5Finish,playerQuestsGui.d5Finish},{playerQuestsGui.QuestSlot6Finish,playerQuestsGui.d6Finish}} local questSlots = {playerQuestsGui.QuestSlot1,playerQuestsGui.QuestSlot2,playerQuestsGui.QuestSlot3,playerQuestsGui.QuestSlot4,playerQuestsGui.QuestSlot5,playerQuestsGui.QuestSlot6} local playerCompletedQuests = ds2("playercompletedquests",player):Get({}) table.insert(playerCompletedQuests,questValue) ds2("playercompletedquests",player):Set(playerCompletedQuests) for i,questSlot in pairs(questSlots) do if questSlot:WaitForChild("QuestValue").Value == questValue then player:WaitForChild("Quests")[questValue].Value = false questSlot:WaitForChild("QuestCompleted").Value = true questFinishedSlots[i][1].Visible = true questFinishedSlots[i][2].Visible = true QuestManager.UpdateText(player,questValue,finishValue,finishValue) break end end end function QuestManager.CheckQuests(alivePlayers,deadPlayers,inGamePlayers,mapName) print("---------Missions Info----------") local map repeat map = game.ReplicatedStorage.Maps[mapName] until map repeat wait() until map and map:FindFirstChild("Difficulty") local difficultyValue = map:FindFirstChild("Difficulty").Value print(map:FindFirstChild("Difficulty").Value) for i, player in pairs(inGamePlayers) do local playerQuestsGui = player.PlayerGui.QuestGui.Frame.Quests local questSlots = {playerQuestsGui.QuestSlot1,playerQuestsGui.QuestSlot2,playerQuestsGui.QuestSlot3,playerQuestsGui.QuestSlot4,playerQuestsGui.QuestSlot5,playerQuestsGui.QuestSlot6} repeat wait() until player:FindFirstChild("Quests") repeat wait() until player:FindFirstChild("Quests"):FindFirstChild("Quest105") if player.Quests.Quest1.Value then --makePopupEvent:FireClient(player,) if Quests.Quest1.Requirments.Requirment1(player,alivePlayers,map,difficultyValue) then Quests.Quest1.RewardPlayer(player) end end if player.Quests.Quest2.Value then if Quests.Quest2.Requirments.Requirment1(player,alivePlayers,map,difficultyValue) then Quests.Quest2.RewardPlayer(player) end end if player.Quests.Quest3.Value then if Quests.Quest3.Requirments.Requirment1(player,alivePlayers,map,difficultyValue) then Quests.Quest3.RewardPlayer(player) end end if player.Quests.Quest4.Value then if Quests.Quest4.Requirments.Requirment1(player,alivePlayers,map) then Quests.Quest4.RewardPlayer(player) end end if player.Quests.Quest5.Value then if Quests.Quest5.Requirments.Requirment1(player) then Quests.Quest5.RewardPlayer(player) end end if player.Quests.Quest6.Value then if Quests.Quest6.Requirments.Requirment1(player) then Quests.Quest6.RewardPlayer(player) end end if player.Quests.Quest7.Value then if Quests.Quest7.Requirments.Requirment1(player,alivePlayers,map,difficultyValue) then Quests.Quest7.RewardPlayer(player) end end if player.Quests.Quest8.Value then if Quests.Quest8.Requirments.Requirment1(player,alivePlayers,deadPlayers,map,difficultyValue) then Quests.Quest8.RewardPlayer(player) end end if player.Quests.Quest102.Value then if GemQuests.Quest102.Requirments.Requirment1(player,alivePlayers,deadPlayers,map) then GemQuests.Quest102.RewardPlayer(player) end end if player.Quests.Quest103.Value then if GemQuests.Quest103.Requirments.Requirment1(player,alivePlayers,deadPlayers,map) then GemQuests.Quest103.RewardPlayer(player) end end if player.Quests.Quest104.Value then if GemQuests.Quest104.Requirments.Requirment1(player,alivePlayers,deadPlayers,map,difficultyValue) then GemQuests.Quest104.RewardPlayer(player) end end if player.Quests.Quest105.Value then if GemQuests.Quest105.Requirments.Requirment1(player,alivePlayers,deadPlayers,map,difficultyValue) then GemQuests.Quest105.RewardPlayer(player) end end end print("--------------------------------") return true end return QuestManager