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

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

Asked by 8 years ago

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

Log in to vote
0
Answered by 8 years ago

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().
Ad
Log in to vote
0
Answered by 8 years ago

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.

0
Oh OK, I got it now. Thanks! iAwakening 0 — 8y

Answer this question