Defining variables with no value

Quick question, like year ago I could just do

local var

and it would not show up as an error, but now whenever I do that it shows up red and errors, was there an update regarding on how to use these or what?

It’s not exactly an error, it’s just a warning that tells you that the variable currently has no defined value. It goes away if you give it a value or later on in the script give it a value.

local var

if var then --Underlines cause var does not have an assigned value

end

--Assigning nil to var will remove the error, or just give it a value
--Before it reached the if statement

Or I think you mean that it says that it’s never used, in that case you can just prefix it with _ or eventually just use it

local var --Currently will warn cause unused
var = 5 --After this line the warning goes away cause it's used now

--or

local _var --Will not warn
3 Likes

what @EmbatTheHybrid said ^

1 Like