Hi,
I have a local variable in my script that can sometimes be turned off or in other terms stop existing (it's hard to explain). I'm referencing this local variable, however, when it stops existing my if statement referencing the local variable breaks the script. Is there a way to make my script check if the particular local variable still exists prior to running the command?
Thanks.
simply test for it's existence, if you use a variable that returns nil, it most likely does not exist, also, nil can also represent false in lua
if -variable- then --do stuff end
replace -variable- with the variable to test
You should rewrite your script, so its always is prepared for any conditions. If you really, i mean REALLY can't, use ypcall:
ypcall(function() --put any dangerous code here that may crash your script. end)
Since you did not show us your script, I can't be certain that this solution is right for you.