Feedback on my code please

Greetings fellow programmers! I need some feedback & support on the code that I typed last night. I’m learning Lua (Started learning 1 month ago) and I learned about the If else statements & Input. I typed out the code in Replit.

CODE:

var = "Cookies"
print (var.. " are very yummy!!")

--------------------------------------------------------------------
print ("----------------------")
--------------------------------------------------------------------

name = "MachineCoder"
if name == "MachineCoder"
then
	print ("MachineCoder activated!")
end

--------------------------------------------------------------------
print ("----------------------")
--------------------------------------------------------------------

cheez = "cheese"
if cheez == "cheese"
then print(" Me lykes cheese! Yum Yum. " )
end

--------------------------------------------------------------------
print ("----------------------")
--------------------------------------------------------------------

numb = 5

if numb == 5 -- Change this value to any number except 5 to get the flase print statement.
then print("The number is 5")
else
	print ("The number is not 5")
end

--------------------------------------------------------------------
print ("----------------------")
--------------------------------------------------------------------

LuaU = "Lua"
if LuaU == "Lua"
then print(LuaU.. " is life! ")
else
	print("This is not Lua dude! This is Ruby.")
end

--------------------------------------------------------------------
print ("----------------------")
--------------------------------------------------------------------

io.write("What's your name?")
name = io.read()

if name == "MachineCoder"
then print ("Hey there!")
else
	print(" I think I don't know you. Have a great day!")
end

--------------------------------------------------------------------
print ("----------------------")
--------------------------------------------------------------------

--[[io.write("Your username?")
username = io.read()
if username == "Coder"
then print("Hello CODER!")
else
print(" I think I don't know you. Have a great day!")
end]]

--------------------------------------------------------------------
print ("----------------------")
--------------------------------------------------------------------




And I don’t know why this line of code isn’t working in Roblox Studio:

io.write("What's your name?")
name = io.read()

if name == "MachineCoder"
then print ("Hey there!")
else
	print(" I think I don't know you. Have a great day!")
end

Any solution?

Waiting for your feedback and support @Programmers

:memo: - Harmony

you can’t use io.write() and io.read() in roblox

Oh. I typed it out because it is in one of the Lua tutorials. Thank you btw!

yea they should work in vanilla lua, that’s probably why you saw it there

1 Like

So is the code perfect? I mean, are there any mistakes in my code? I’m very curious to know as this is the first time typing the if-else statements & input code.

the code seems like it should work fine(besides the io part of it)

1 Like