Dumb Questions I have as Always.
Just to clear up a couple of things, I’m not talking about stuff like _G
or ModuleScripts
, I’m talking about just Regular Variables.
So anyway, What I’m asking is to where use Global Variables, If we are putting this into code, we will have this:
_G.Array = {} -- Deprecated?
Variable = "Привіт Україно!" -- Global Variable (accessible within the Entire script)
local Var = 13 -- Local Variable (accessible within a Scope)
In Luau, It appears people to tend use local
when creating Variables, which Looks something like this:
local Integer = 123 -- numbers
local Text = "Hallo Deutschland!" -- (Auf Deutsch sprechen!)
local Float = 123.456 -- (or "Double," cry about it)
-- people also tend to make the first Letter or a Variable lowercase?
local userData = {} -- Adding a Space to Line up Variables
local arraytoUse = {} -- ok.
local dogStorage = {} -- not what It sounds
local cashDrawer = {} -- hmmmmmmmmmm...
-- you know, whatever names people have for their stuff
But when adding a Global Within a function, it underlines the Variable and says to use local
instead:
function Monaco() -- Whatever Country I could name of the top of my head
Global = "Hello" -- Underlines?
end)
Are the only uses of a Global Variable just at the Beginning of a Script or outside of any functions?
(Sorry about all the Random stuff I put here, I get “Professional Environment” but still, I want to have fun sometimes)