My lua project wont run properly (School assignment)

Problem description:
My code in Lua wont run, when i make a new project in Lua and type in "print(“hello”) it runs but my when i copy paste my code in the same project it wont run

Expected behavior:
it is supposed to show what i coded

Actual behavior:
not showing anything

Could you please share the repl link? This would help us helping you

https://replit.com/@TaxCollector011/Lua-project

does it run locally? as that already will help you understand the errors

Run localy? im pretty new to this

it doent show that i have any errors

on your computer? Did you try to run it ?
Also can you confirm if this is a school assignment off any sort?

yes this is a school assignment and, i have run it mutble times and i am on my computer

Please adjust the title as the help you will receive here will differ with school assignments.
No code but hints.
I would suggest to look at your while True loop and be sure you do not get stuck there … as in the program is infinitively looping …

i have looked at it and cant find anything wrong, as i said im very new to Lua

As this is an assignment I cannot give you fixed code.
I can tell you that if you have/use a while True loop, this will run continuously until an exit condition is met:

For example:

-- Set up a variable to count the number of times the loop has run
local count = 0

-- Infinite loop with exit condition
while true do
  -- Do something in the loop
  print("This is an infinite loop")

  -- Increment the count variable
  count = count + 1

  -- Check if the count has reached a certain number
  if count >= 10 then
    -- If the count is greater than or equal to 10, break out of the loop
    break
  end
end

-- Print a message to indicate that the loop has ended
print("The infinite loop has ended")

but i want my code to run infinitely

You have two loops, I guess one yes and one not

i have removed and it still doesnt work

it workked like yesterday and then suddenldy it doent, and i did have both in the code

if you remove the infinite loop it works for me … maybe you forgot you are asking input from the user and you need to type something …

PS: change the post title, not the repl title so we all know it is for school :slight_smile:

ok but i did tred removing borth and it still doent work

I forked your repl and it works. I just type a number (as the program wants) and if moves on. Maybe it is not doing the right thing, but that I did not try to understand. I just checked about errors

ok i can try that break thing if it works

Add some prints here and there as a way to see where the program gets stuck. This is a simple way that always helps.

PS: I am going offline, hope somebody can jump in and help you

1 Like