Randomizer AI problem

I want to make some kind of a “Guess the State Capital” game. There is a randomizer AI that randomizes the question the players are given. The problem is that when I tried to type the right answer and submit it, the question doesn’t change. I’ve tried looking on youtube and other roblox fourm sites, but unfortunately, I couldn’t find the solution to this problem. So I’m asking you developers to help me with this.

Evidence #1: Layout:
Screenshot 2021-04-09 223044
Screenshot 2021-04-09 223520

Evidence #2: Script Snippet:

--Variables--
local SubmitButton = script.Parent.SubmitFrame.SubmitButton --The submit button
local AnswerBox = script.Parent.AnswerFrame.AnswerBox --Where the player types the answer
local NameOfState = script.Parent.TextBackground.StateNameLabel --The name of the state
local StatePickNumber = math.random(1, 5) -- Random number

if StatePickNumber == 1 then --If the StatePickNumber becomes equal to 1
	NameOfState.Text = "Washington"
elseif StatePickNumber == 2 then --If the StatePickNumber becomes equal to 2
    NameOfState.Text = "Oregon"
elseif StatePickNumber == 3 then --If the StatePickNumber becomes equal to 3
    NameOfState.Text = "California"
elseif StatePickNumber == 4 then --If the StatePickNumber becomes equal to 4
    NameOfState.Text = "Nevada"
elseif StatePickNumber == 5 then --If the StatePickNumber becomes equal to 5
    NameOfState.Text = "Idaho"
end

SubmitButton.MouseButton1Down:Connect(function()
	if StatePickNumber == 1 and AnswerBox.Text == "Olympia" then --Washington Correct
		CorrectSound:Play()
		local NewStatePickNumber = math.random(1,5) --Makes the StatePickNumber change value
		StatePickNumber = NewStatePickNumber --Makes the StatePickNumber change value
	elseif StatePickNumber == 1 and AnswerBox.Text ~= "Olympia" then --Washington NOT Correct
		IncorrectSound:Play()
	elseif StatePickNumber == 2 and AnswerBox.Text == "Salem" then --Oregeon Correct
		CorrectSound:Play()
		local NewStatePickNumber = math.random(1,5) --Makes the StatePickNumber change value
		StatePickNumber = NewStatePickNumber
	elseif StatePickNumber == 2 and AnswerBox.Text ~= "Salem" then --Oregeon NOT Correct
		IncorrectSound:Play()
	elseif StatePickNumber == 3 and AnswerBox.Text == "Sacramento" then --California Correct
		CorrectSound:Play()
		local NewStatePickNumber = math.random(1,5) --Makes the StatePickNumber change value
		StatePickNumber = NewStatePickNumber
	elseif StatePickNumber == 3 and AnswerBox.Text ~= "Sacramento" then --California NOT Correct
		IncorrectSound:Play()
	elseif StatePickNumber == 4 and AnswerBox.Text == "Carson City" then --Nevada Correct
		CorrectSound:Play()
		local NewStatePickNumber = math.random(1,5) --Makes the StatePickNumber change value
		StatePickNumber = NewStatePickNumber
	elseif StatePickNumber == 4 and AnswerBox.Text ~= "Carson City" then --Nevada NOT Correct
		IncorrectSound:Play()
	elseif StatePickNumber == 5 and AnswerBox.Text == "Boise" then --Idaho Correct
		CorrectSound:Play()
		local NewStatePickNumber = math.random(1,5) --Makes the StatePickNumber change value
		StatePickNumber = NewStatePickNumber
	elseif StatePickNumber == 5 and AnswerBox.Text ~= "Boise" then --Idaho NOT Correct
		IncorrectSound:Play()
    end
end)

Sorry if I put too much! I’m still working on this project as I type this. PM me if you have the answer.

In this script, it would only play the incorrect sound whenever they get it wrong and not actually end up changing the question. Just add a function which changes the state number and change the new number after the submit button is clicked. Like this:

--Variables--
local SubmitButton = script.Parent.SubmitFrame.SubmitButton --The submit button
local AnswerBox = script.Parent.AnswerFrame.AnswerBox --Where the player types the answer
local NameOfState = script.Parent.TextBackground.StateNameLabel --The name of the state
local StatePickNumber = math.random(1, 5) -- Random number

function changestate()
	if StatePickNumber == 1 then --If the StatePickNumber becomes equal to 1
		NameOfState.Text = "Washington"
	elseif StatePickNumber == 2 then --If the StatePickNumber becomes equal to 2
		NameOfState.Text = "Oregon"
	elseif StatePickNumber == 3 then --If the StatePickNumber becomes equal to 3
		NameOfState.Text = "California"
	elseif StatePickNumber == 4 then --If the StatePickNumber becomes equal to 4
		NameOfState.Text = "Nevada"
	elseif StatePickNumber == 5 then --If the StatePickNumber becomes equal to 5
    		NameOfState.Text = "Idaho"
	end
end

changestate()

SubmitButton.MouseButton1Down:Connect(function()
	if StatePickNumber == 1 and AnswerBox.Text == "Olympia" then --Washington Correct
		CorrectSound:Play()
		local NewStatePickNumber = math.random(1,5) --Makes the StatePickNumber change value
		StatePickNumber = NewStatePickNumber --Makes the StatePickNumber change value
	elseif StatePickNumber == 1 and AnswerBox.Text ~= "Olympia" then --Washington NOT Correct
		IncorrectSound:Play()
	elseif StatePickNumber == 2 and AnswerBox.Text == "Salem" then --Oregeon Correct
		CorrectSound:Play()
		local NewStatePickNumber = math.random(1,5) --Makes the StatePickNumber change value
		StatePickNumber = NewStatePickNumber
	elseif StatePickNumber == 2 and AnswerBox.Text ~= "Salem" then --Oregeon NOT Correct
		IncorrectSound:Play()
	elseif StatePickNumber == 3 and AnswerBox.Text == "Sacramento" then --California Correct
		CorrectSound:Play()
		local NewStatePickNumber = math.random(1,5) --Makes the StatePickNumber change value
		StatePickNumber = NewStatePickNumber
	elseif StatePickNumber == 3 and AnswerBox.Text ~= "Sacramento" then --California NOT Correct
		IncorrectSound:Play()
	elseif StatePickNumber == 4 and AnswerBox.Text == "Carson City" then --Nevada Correct
		CorrectSound:Play()
		local NewStatePickNumber = math.random(1,5) --Makes the StatePickNumber change value
		StatePickNumber = NewStatePickNumber
	elseif StatePickNumber == 4 and AnswerBox.Text ~= "Carson City" then --Nevada NOT Correct
		IncorrectSound:Play()
	elseif StatePickNumber == 5 and AnswerBox.Text == "Boise" then --Idaho Correct
		CorrectSound:Play()
		local NewStatePickNumber = math.random(1,5) --Makes the StatePickNumber change value
		StatePickNumber = NewStatePickNumber
	elseif StatePickNumber == 5 and AnswerBox.Text ~= "Boise" then --Idaho NOT Correct
		IncorrectSound:Play()
    end
	local NewStatePickNumber = math.random(1,5) --Makes the StatePickNumber change value
	StatePickNumber = NewStatePickNumber
	changestate()
end)