Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How can I return the question if it is incorrect and making it print "Incorrect"?

print ("What is 5+10") while input ~= "15" do input=io.read() if input == "15" then print("Congrates") end if not input then print ("Wrong") return end end

It works, but it does not print "Wrong"

2 answers

3 things:

  1. No, this script doesn't work if it doesn't print "wrong" when the answer is wrong.
  2. This is how its done:
print ("What is 5+10") 
Game:GetService("LogService").MessageOut:connect(function(Msg)
	if msg == "15" then 
		print("Congrates") 
	elseif msg ~= "15" then 
		print ("Wrong")  
	end 
end)
  1. If that's not what you want change return to return().

Another solution could be:

print ("What is 5 + 10?")
local i = 5
local o = 10

if i + o == 15
then print ("Congrates!")
else
print ("Wrong!")
end                             ------These go together BTW :)
if i + 0 ~= 15
then print ("Wrong!")
end

But, that's the longer way to do it.

I'm assuming this is what you were asking.

1 comment

0

Oh OK, I got it now. Thanks!

This discussion is preserved as it was. New answers, comments, and votes are closed.