Well I am learning Lua at the moment and I wanted to write a little script. It's just for practice and understanding how Lua is working.
local name = io.read()
if name == Test
then print("Right")
else print("Wrong")
end
Normally the output should be "Right" if I enter "Test" but it always prints "Wrong". I tried it many times and wrote the code in other forms but didn't get my solution.
Can anyone help me please?
You're missing a set of quotation marks.
This:
if name == Test
compares the values of two variables, name and Test.
You want this:
if name == "Test"
Lua doesn't require variables to be declared, so this is an easy mistake to make.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With