This script is going to be released to the public, if an error occurred… people can come to me for help. It will be uploaded to a group and since i’m making it… its better that people know who actually made the script so they can be helped.
Please describe what you mean by local variables and what part of the script you mean…
Duly noted, it becomes hard to remember to make more variables as I end up forgetting that I should add it and I end up just writing extra code.
I used an empty if block due to the if not part having issues.
local function test()
x = math.random(1, 5)
print(x) -- might print 3
print(x) -- might print 5
Every time the function was called, it wrote to the same variable. Code using it after the function might not work as intended because of this. Variables should have the shortest lifespan possible.
local x = 5
x = 6
Does NOT make x a global variable. It just reassigns it to a new value. Global variables are declared (initialized, i.e. set for the first time) without the local keyword. Also, local variables are faster to access than globals. But that is not why you use locals. You use them because they are good practice.
What do you mean? Instead of this:
if x then
if not x then
Eliminates the need for an else block in the first place.