Why use local in variables and what if you don't?

This may sound like a dumb question… it probably is. But, let’s be honest. Most of use have wondered why use local in variables?

Everyone’s seen this phenomenon before. In tutorials and other people’s scripting.
Some use;

x = 1
repeat
 x = x + 1
until x == 5

While others do;

local x = 1
repeat
 x = x + 1
until x == 5

And it’s completely acceptable. But why?


It’s probably for categorising or ease of readability but other than that what gives? I’ve asked some developers and most don’t even know why. So, might as well clear this one out while we’re here.

2 Likes

This article might answer your question better.

2 Likes

Simple questions, simple answers. Straight to the point.

1 Like

Game doesn’t know what does x mean. (Ah I know what you mean now)