So I was looking at Sceleratis's Addonis Core and he starts off with:
local _G = _G local script = script local game = game local workspace = workspace local getfenv = getfenv local setfenv = setfenv local getmetatable = getmetatable local setmetatable = setmetatable local math = math local print = print local warn = warn local error = error local coroutine = coroutine local pcall = pcall local ypcall = ypcall local xpcall = xpcall local select = select local rawset = rawset local rawget = rawget local rawequal = rawequal local pairs = pairs local ipairs = ipairs local next = next local newproxy = newproxy local os = os local tick = tick local loadstring = loadstring local tostring = tostring local tonumber = tonumber local unpack = unpack local string = string local Instance = Instance local type = type local wait = wait local require = require local table = table local Enum = Enum
Is there any reason for this/does it do anything?
For those of scripters who are anal about performance, a useful piece of information is that global variables are about 10x slower for each access than local variables. When you're running stuff in tight loops, or as an addon, that sort of stuff stacks up.
There's also the upvalues argument. Occasionally I will (for example) insert all of the values I'm using into locals ahead of time because then they are accessed by functions as upvalues instead of fetching them from the global environment. This avoids variable value inconsistency, as you can expect each variable to point to what it was defined as (For more information on environments, look here and refer to 5.1)
So, to those of you who thought it's for nothing, now you know better.
The most reasonable reason would be that it would be easier to target them or hes just lazy so he made them the same variable but in a easier way since roblox doesnt target it or auto complete it so he made those variables so roblox does target it.