I have a ScreenGui (named "computerScreen") that is given to a player when sitting down on a Seat part in the game. Whenever the "questionNumber" (an IntValue) changes, the question and answer to it change with that number. Here's the LocalScript (player.PlayerGui.computerScreen.changeQuestions):
local plr = game.Players.LocalPlayer
local maxQuestions = 2
local question1 = script.Parent.question1
local question2 = script.Parent.question2
local answer1 = script.Parent.answer1
local answer21 = script.Parent.answer21
local answer22 = script.Parent.answer22
script.Parent.scriptInput.FocusLost:Connect(function()
print("changed textBox")
if script.Parent.scriptInput.Text == "" then
script.Parent.questionNumber.Value = math.random(1, maxQuestions)
print('was "", reset value to '..script.Parent.questionNumber.Value)
else
local text = script.Parent.scriptInput
local number = script.Parent.questionNumber
if number.Value == 1 then
if text.Text == answer1.Value then
print('"'..text.Text..'"')
game.ReplicatedStorage.payProgrammers:FireServer()
number.Value = math.random(1, maxQuestions)
print('Answer was '..answer1.Value..', got '..text.Text)
else
print('"'..text.Text..'"'..", was not equal to '' or "..answer1.Value)
number.Value = math.random(1, maxQuestions)
end
elseif number.Value == 2 then
if text.Text == answer21.Value or answer22.Value then
print('"'..text.Text..'", answer should be '..answer21.Value..' or '..answer22.Value)
game.ReplicatedStorage.payProgrammers:FireServer()
number.Value = math.random(1, maxQuestions)
else
print('"'..text.Text..'"'..", was not equal to '' or "..answer21..' or '..answer22)
number.Value = math.random(1, maxQuestions)
end
elseif number.Value == 3 then
number.Value = math.random(1, maxQuestions)
elseif number.Value == 4 then
number.Value = math.random(1, maxQuestions)
elseif number.Value == 5 then
number.Value = math.random(1, maxQuestions)
end
end
end)
script.Parent.questionNumber.Changed:Connect(function(item)
print("changed value of question")
local context = script.Parent.whatToDo
local value = script.Parent.questionNumber.Value
if value == 1 then
print("something1")
context.Text = question1.Value
script.Parent.scriptInput.Text = ""
elseif value == 2 then
print("something2")
context.Text = question2.Value
script.Parent.scriptInput.Text = ""
elseif value == 3 then -- NOT using this yet
print("something3")
script.Parent.scriptInput.Text = ""
elseif value == 4 then -- NOT using this yet
print("something4")
script.Parent.scriptInput.Text = ""
elseif value == 5 then -- NOT using this yet
print("something5")
script.Parent.scriptInput.Text = ""
end
end)
Bugs I'm seeing in this code: Not sure what is causing this, but the game.ReplicatedStorage.payProgrammers is sometimes fired when the "scriptInput" 's text is not equal to the string to what the answer it (ex. answer1 or answer21). Also, not all of the time will the question change when the "questionNumber" value is changed.

2 comments
I recommend learning about tables so you don't have to have a separate 'if' branch for every question and avoiding have the same sort of code over and over again. http://lua-users.org/wiki/TablesTutorial
alright, ill take a look at it. i knew this was a problem but couldnt find a way over it