Daily Challenges System not Working at all

Hey there! So I’ve made a pretty complicated GUI, with a Modules folder with scripts, a MainModule script, and a big Events folder, along with some server-side code as well, but it isn’t working. The little bar won’t update, the percentage won’t change, etc.

My MainModule localscript, inside a ScrollingFrame, inside the ScreenGui:

local possibleQuests = {
	["QuestOne"] = "Bragging Rights",
	["QuestTwo"] = "Winner's Pool",
	["QuestThree"] = "Campfire",
	["QuestFour"] = "Setting Up Camp",
	["QuestFive"] = "Lumberjack",
	["QuestSix"] = "Play-A-Day"
}
local possibleDescriptions = {
	["TextOne"] = "Win a game of Alone!",
	["TextTwo"] = "Win 5 games of Alone!",
	["TextThree"] = "Set up a campfire in Alone!",
	["TextFour"] = "Set up 5 tents Alone!",
	["TextFive"] = "Mine 30 trees!",
	["TextSix"] = "Play for a day overall in Alone!"
}
local questRandom = math.random(1, 6)
if questRandom == 1 then
	script.Parent.QuestName.Text = "Bragging Rights"
	script.Parent.Text.Text = "Win a game of Alone!"
	script.Parent.Values.Quest.Value = 1
elseif questRandom == 2 then
	script.Parent.QuestName.Text = "Winner's Pool"
	script.Parent.Text.Text = "Win 5 games of Alone!"
	script.Parent.Values.Quest.Value = 2
elseif questRandom == 3 then
	script.Parent.QuestName.Text = "Campfire"
	script.Parent.Text.Text = "Set up a campfire in Alone!"
	script.Parent.Values.Quest.Value = 3
elseif questRandom == 4 then
	script.Parent.QuestName.Text = "Setting Up Camp"
	script.Parent.Text.Text = "Set up 5 tents Alone!"
	script.Parent.Values.Quest.Value = 4
elseif questRandom == 5 then
	script.Parent.QuestName.Text = "Lumberjack"
	script.Parent.Text.Text = "Mine 30 trees!"
	script.Parent.Values.Quest.Value = 5
elseif questRandom == 6 then
	script.Parent.QuestName.Text = "Play-A-Day"
	script.Parent.Text.Text = "Play for a day overall in Alone!"
	script.Parent.Values.Quest.Value = 6
end

Next, my LocalScript inside Modules folder:

local GUI = script.Parent.Parent.Parent.Parent
local MainFrame = script.Parent.Parent.Parent
local Folder = script.Parent.Parent
local QName = Folder.Name
local QText = Folder.Text
local overall = Folder.Unfilled
local completed = Folder.Filled
local completedText = Folder.AmountDone
local quest = Folder.Values.Quest
game.ReplicatedStorage.DailyChallenges.ChallengeOneValueChanged.OnClientEvent:connect(function()
	print("hi")
	script.Parent.Parent.Events.QuestOne:Fire()
end)
game.ReplicatedStorage.DailyChallenges.ChallengeOneValueChanged.OnClientEvent:connect(function()
	print("hi")
	script.Parent.Parent.Events.QuestTwo:Fire()
end)
game.ReplicatedStorage.DailyChallenges.ChallengeThreeValueChanged.OnClientEvent:connect(function()
	print("hi")
	script.Parent.Parent.Events.QuestThree:Fire()
end)
game.ReplicatedStorage.DailyChallenges.ChallengeFourValueChanged.OnClientEvent:connect(function()
	print("hi")
	script.Parent.Parent.Events.QuestFour:Fire()
end)
game.ReplicatedStorage.DailyChallenges.ChallengeFiveValueChanged.OnClientEvent:connect(function()
	print("hi")
	script.Parent.Parent.Events.QuestFive:Fire()
end)
game.ReplicatedStorage.DailyChallenges.ChallengeSixValueChanged.OnClientEvent:connect(function()
	print("hi")
	script.Parent.Parent.Events.QuestSix:Fire()
end)

quest.Changed:Connect(function()
	print("new quest value found, now it is", quest.Value)
	if quest.Value == 1 then
		print("Player's new quest is Quest number 1")
		local CurrentWins = game.Players.LocalPlayer.Wins
		local NeededWins = 1
		script.Parent.Parent.Events.QuestOne.Event:Connect(function()
			script.Parent.Parent.Filled.Size.X = CurrentWins.Value / NeededWins
			script.Parent.Parent.AmountDone.Text = CurrentWins.Value / NeededWins * 100 .. "%"
		end)
	elseif quest.Value == 2 then
		print("Player's new quest is Quest number 2")
		local CurrentWins = game.Players.LocalPlayer.Wins.Value
		local NeededWins = 5
		script.Parent.Parent.Events.QuestTwo.Event:Connect(function()
			script.Parent.Parent.AmountDone.Text = CurrentWins.Value / NeededWins * 100 .. "%"
			script.Parent.Parent.Filled.Size.X = CurrentWins.Value / NeededWins
		end)
	elseif quest.Value == 3 then
		print("Player's new quest is Quest number 3")
		local CurrentWins = game.Players.LocalPlayer.FiresPlaced.Value
		local NeededWins = 1
		script.Parent.Parent.Events.QuestThree.Event:Connect(function()
			script.Parent.Parent.AmountDone.Text = CurrentWins.Value / NeededWins * 100 .. "%"
			script.Parent.Parent.Filled.Size.X = CurrentWins.Value / NeededWins
		end)
	elseif quest.Value == 4 then
		print("Player's new quest is Quest number 4")
		local CurrentWins = game.Players.LocalPlayer.TentsPlaced.Value
		local NeededWins = 5
		script.Parent.Parent.Events.QuestFour.Event:Connect(function()
			script.Parent.Parent.AmountDone.Text = CurrentWins.Value / NeededWins * 100 .. "%"
			script.Parent.Parent.Filled.Size.X = CurrentWins.Value / NeededWins
		end)
	elseif quest.Value == 5 then
		print("Player's new quest is Quest number 5")
		local CurrentWins = game.Players.LocalPlayer.TreesMined.Value
		local NeededWins = 30
		script.Parent.Parent.Events.QuestFive.Event:Connect(function()
			script.Parent.Parent.AmountDone.Text = CurrentWins.Value / NeededWins * 100 .. "%"
			script.Parent.Parent.Filled.Size.X = CurrentWins.Value / NeededWins
		end)
	elseif quest.Value == 6 then
		print("Player's new quest is Quest number 6")
		local CurrentWins = game.Players.LocalPlayer.SecondsPlayed.Value
		local NeededWins = 86400
		script.Parent.Parent.Events.QuestSix.Event:Connect(function()
			script.Parent.Parent.AmountDone.Text = CurrentWins.Value / NeededWins * 100 .. "%"
			script.Parent.Parent.Filled.Size.X = CurrentWins.Value / NeededWins
		end)
	end
end)

And finally my server-side code:

game.Players.PlayerAdded:Connect(function(player)
	local Wins = player:WaitForChild("Wins")
	local Fires = player:WaitForChild("Fires")
	local Tents = player:WaitForChild("Tents")
	local Trees = player:WaitForChild("Trees")
	local Seconds = player:WaitForChild("Seconds")
	print("Success!  Wins, Fires, Tents, Trees, and Seconds variables were defined, loaded, and rendered successfully in ",player.Name,"!  Ready for Changed functions.")
	Wins.Changed:Connect(function()
		print("Wins changed to ", Wins.Value, "firing.")
		game.ReplicatedStorage.DailyChallenges.ChallengeOneValueChanged:FireClient(player)
	end)
	Fires.Changed:Connect(function()
		print("Fires changed to ", Fires.Value, "firing.")
		game.ReplicatedStorage.DailyChallenges.ChallengeThreeValueChanged:FireClient(player)
	end)
	Tents.Changed:Connect(function()
		print("Tents changed to ", Tents.Value, "firing.")
		game.ReplicatedStorage.DailyChallenges.ChallengeFourValueChanged:FireClient(player)
	end)
	Trees.Changed:Connect(function()
		print("Trees changed to ", Trees.Value, "firing.")
		game.ReplicatedStorage.DailyChallenges.ChallengeFiveValueChanged:FireClient(player)
	end)
	Seconds.Changed:Connect(function()
		print("Seconds changed to ", Seconds.Value, "firing.")
		game.ReplicatedStorage.DailyChallenges.ChallengeSixValueChanged:FireClient(player)
	end)
end)

I want the system to update the bar, and the percentage as soon as the values change.

A video of the problem occurring:

Any help is appreciated. Thanks so much! (Going to bed, will read all replies in the morning.)

1 Like

You got repetition in your code. For security, make sure to check the quest server sided. Try to make your code more understandable and more smooth to find any bugs. Your code is very Unorganized and unsecured. You also only need 1 remote event for the quest.
Server Script:

local QuestRemote = game.ReplicatedStorage.QuestRemote --Your remote event
Quest = {
   1 = {Name = "Bragging Rights", Description = "Win a game of Alone!", },
   2 = {Name = "Winner's Pool", Description = "Win 5 games of Alone!", },
   3 = {Name = "Campfire", Description = "Set up a campfire in Alone!", },
   4 = {Name = "Setting Up Camp", Description = "Set up 5 tents Alone!", },
   5 = {Name = "Lumberjack", Description = "Mine 30 trees!", },
   6 = {Name = "Play-A-Day", Description = "Play for a day overall in Alone!", },
}

QuestRemote.OnServerEvent:Connect(function(plr,Action)
        if Action == "PickQuest" then
               local ChoosenQuest
               ChoosenQuest =  Quest[math.random(#quest)]
               QuestRemote:FireClient(plr, "BroadcastChoosenQuest", ChoosenQuest.Name, ChoosenQuest.Description)
                --Do the code for checking if the quest is done or something here then fire back to the client. 
        end
end)

Client Script:

local QuestRemote = game.ReplicatedStorage.QuestRemote --Your remote event
QuestRemote.OnClientEvent:Connect(function(Action,Arg1,Arg2)
       if Action = "BroadcastChoosenQuest" then
              local Name = Arg1
              local Description = Arg2
              --Change the ui's here Depending on the varables above
       end
end)

Hey, just got to testing this and the 1 is underlined in red, and it says
10:01:03.273 - ServerScriptService.DailyChallenges:3: '}' expected (to close '{' at line 2) near '='

Thanks! :grinning:

Mason, the numbers! Where are they coming from!?

You need to optimize your script and make it more readable before we can help you bud. I’m a bit too busy to help with optimizing your code, but I bet somebody else could. I will be glad to help you out once you get the optimizing done.

Also, when you optimize code, that is often when you solve bugs. When working on a big game of mine, people kept complaining about hitreg. I fixed it simply by reducing the lines of code and making it more efficient. When developers say that your code should be efficient, ya gotta take that advice bro. It will help you out SO much in the long run in large-scale projects.

Hope that started to help. Lemme know when progress is made :slight_smile:

(Also, that first quote is from Black Ops, in case ya didn’t play it XD)

Optimisation isn’t the same as fixing bugs. You should be trying to read the code and helping to answer the question or better the code. If you have optimisation techniques that can also improve the code, you can post them in a response to the thread.

Code optimisation is the practice of improving code efficiency. It would help us all if you happened to explain what optimisations you have in mind.

1 Like

Sorry, I wasn’t clear. That was my bad.

The type of optimization I had in mind was removing repetition. I had in mind that by optimizing he might catch a bug or too as well that he missed before. However, if he can’t discover what is wrong after optimizing, at least now we can read it more :slight_smile:

He misplaced a comma, I think.

Its not too hard to fix on your own.