Background color won't change

CodePanel.rbxm (10.1 KB)

Script
local Frame = script.Parent:WaitForChild('Frame')
local Enter = Frame:WaitForChild('Enter')
local TimeLeft = Frame:WaitForChild('TimeLeft')
local CodeHere = Frame:WaitForChild('CodeHere')
local Solve = Frame:WaitForChild('Solve')
local Dots = Frame:WaitForChild('Dots')


local CurrentLevel = 1
local CurrentQuestion = {0, 0, 0}
local EnterButtonEnabled = true
local Levels = {
	{
		VarOne={5, 30},
		VarTwo={3, 20}
	},
	{
		VarOne={10, 40},
		VarTwo={7, 30}
	},
	{
		VarOne={20, 60},
		VarTwo={12, 40}
	},
}


CurrentQuestion[1] = math.random(Levels[CurrentLevel].VarOne[1], Levels[CurrentLevel].VarOne[2])
CurrentQuestion[2] = math.random(Levels[CurrentLevel].VarTwo[1], Levels[CurrentLevel].VarTwo[2])
CurrentQuestion[3] = CurrentQuestion[1] + CurrentQuestion[2]
Solve.Text = tostring(CurrentQuestion[1]).." + "..tostring(CurrentQuestion[2])


function NextLevel()
	if CurrentLevel == #Levels then
		EnterButtonEnabled = false
		Solve.Text = "You Win!"
		wait(1.25)
		CurrentLevel = 1
		CurrentQuestion[1] = math.random(Levels[CurrentLevel].VarOne[1], Levels[CurrentLevel].VarOne[2])
		CurrentQuestion[2] = math.random(Levels[CurrentLevel].VarTwo[1], Levels[CurrentLevel].VarTwo[2])
		CurrentQuestion[3] = CurrentQuestion[1] + CurrentQuestion[2]
		Solve.Text = tostring(CurrentQuestion[1]).." + "..tostring(CurrentQuestion[2])
		for i,v in pairs(Dots:GetChildren()) do
			v.BackgroundColor3 = Color3.fromRGB(204,0,0)
		end
		EnterButtonEnabled = true
	else
		CurrentLevel += 1
		CurrentQuestion[1] = math.random(Levels[CurrentLevel].VarOne[1], Levels[CurrentLevel].VarOne[2])
		CurrentQuestion[2] = math.random(Levels[CurrentLevel].VarTwo[1], Levels[CurrentLevel].VarTwo[2])
		CurrentQuestion[3] = CurrentQuestion[1] + CurrentQuestion[2]
		Solve.Text = tostring(CurrentQuestion[1]).." + "..tostring(CurrentQuestion[2])
	end
end



Enter.MouseButton1Click:Connect(function()
	if EnterButtonEnabled == false then return end
	if CodeHere.Text == tostring(CurrentQuestion[3]) then
		for i,v in pairs(Dots:GetChildren()) do
			if v.Name == ("Remaining"..CurrentLevel) then
				v.BackgroundColor3 = Color3.fromRGB(0,255,0)
			end
		end
		NextLevel()
	else
		CurrentLevel = 1
		for i,v in pairs(Dots:GetChildren()) do
			v.BackgroundColor3 = Color3.fromRGB(255,0,0)
		end
		CurrentQuestion[1] = math.random(Levels[CurrentLevel].VarOne[1], Levels[CurrentLevel].VarOne[2])
		CurrentQuestion[2] = math.random(Levels[CurrentLevel].VarTwo[1], Levels[CurrentLevel].VarTwo[2])
		CurrentQuestion[3] = CurrentQuestion[1] + CurrentQuestion[2]
		Solve.Text = tostring(CurrentQuestion[1]).." + "..tostring(CurrentQuestion[2])
	end
end)
1 Like