N_aps
(N_aps)
July 17, 2021, 9:21pm
#1
What do you want to achieve? trying to make a calculator that calclulates if like 1 < 3 is true or false.
What is the issue? it keeps saying "invalid argument #3 (string expected, got boolean)
Stack Begin and won’t work.
What solutions have you tried so far? Did you look for solutions on the Developer Hub? yes I looked everywhere nothing works.
else
if s.Text == "<" then
a.Text = n1.Text < n2.Text
print(a.Text)
else
if s.Text == ">" then
a.Text = n1.Text > n2.Text
print(a.Text)
n1.Text < n2.Text
returns a boolean value. .Text
is a string property. You will also want to tonumber
the n1.Text
and n2.Text
because the comparison operators on strings will not compare them as you think.
You should be doing something along the lines of:
a.Text = tostring(tonumber(n1.Text) < tonumber(n2.Text))
3 Likes
Kaid3n22
(Kaiden)
July 17, 2021, 9:22pm
#3
use tonumber
on the Text.
if s.Text == "<" then
a.Text = tonumber( n1.Text) < tonumber(n2.Text)
print(a.Text)
else
if s.Text == ">" then
a.Text = tonumber(n1.Text) > tonumber(n2.Text)
print(a.Text)
1 Like
N_aps
(N_aps)
July 17, 2021, 9:24pm
#4
Ohh thanks that works, I should’ve thought of that