Advertisement
KodingKid

Lua Random Number Guesser Game - Throwback scripts #4

May 2nd, 2021
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.44 KB | None | 0 0
  1. math.randomseed(os.time())
  2. rn = math.random(-100,100) --rn = random number
  3. player = {}
  4. player.guess = 0
  5. print(rn)
  6. while (player.guess ~= number) do
  7.   print("Guess a number between -100 and 100")
  8.   player.answer = io.read()
  9.   player.guess = tonumber(player.answer)
  10.  if (player.guess > number) then
  11.     print("Lower")
  12.   elseif (player.guess < number) then
  13.     print("Higher")
  14.   else
  15.     print("YOU WON!!!")
  16.     os.exit()
  17.   end
  18. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement