x= script.Parent x.Changed:connect(function (x) if x.Value ~= "" wait(3) x.Value = "" else wait() end)
I forgot to add the then but for some reason it worked. If i forget the then does it run everything under the if nomatter what the conditions are? Im just curious for learning purposes ofcourse
Mistakes when you code broadly fall into three categories.
These are errors that prevent the computer from understanding what your script means; for example, forgetting an end
or misspelling tehn
; not having (
or )
balanced right; using an invalid name or number like person 2
or 2person
Since the computer gets confused, it just stops when it finds the mistake and does no more work.
These are errors that happen when you try to do something that doesn't make sense, for example "cat" + "dog"
doesn't make sense and Lua will error, complaining that you can't add strings.
The computer can't1 predict that these will happen, so it will execute your script until that problem happens.
This occurs when you program doesn't have any static errors, and doesn't crash, but doesn't do what you intended.
In other words, you wrote a valid program, but you didn't write the program you intended.
The computer can't possibly know your intent (beyond the program that you've given it) so if you make a typo that still ends up being a valid program, it will still run it.
Script Analysis can help catch some of those mistakes.
In general, it's better for errors to happen sooner; you'd prefer a syntax error over a crash; you'd prefer a crash over the program silently doing the wrong thing.
Defensive coding styles will make it more likely that errors happen sooner; as you get more practice you'll learn some through trial, error, and reading.
It can't always. Some tools / programming languages are better at catching these problems ahead-of-time; Lua doesn't, though ROBLOX's Script Analysis will help you catch some of them! ↩