Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

[SOLVED] How do I check for the correct answer to an equation?

Asked by 5 years ago
Edited 5 years ago

Hi, I'm making a script where the player gets 2 random values at the top of the screen, and has to do addition to find the correct answer. I've set up the value part but I've noticed that the script doesnt recognize the correct answers. I expected it to work by doing something like if T.Text == sum then but that doesn't seem to be working. How do I fix this?

01local T = script.Parent
02local Question1 = (math.random(1,10))
03local Q1 = script.Parent.Parent.QuestionBox1
04local p1 = (Question1)
05Q1.Text = Question1
06 
07 
08local Question2 = (math.random(1,10))
09local Q2 = script.Parent.Parent.QuestionBox2
10local p2 = (Question2)
11Q2.Text = Question2
12 
13 
14 
15T.FocusLost:Connect(function(enterPressed)
View all 24 lines...
0
is T.Text a string or a number? Benbebop 1049 — 5y
0
It's the string text of a parent textbox jensar141215 157 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago

I converted the string of T.Text using the tostring() command.

Ad

Answer this question