Second one looks like a module script named G which returns a table named data.
_G looks like a global variable read about it here
Module scripts are generally better to use than _G.
_G is slow since it has to look through a lot of places for the variable.
Module scripts are scripts that return ONE variable when you require them. Usually they return a table with variables/functions inside them.
#Example:
Lets say I have a module script named myModule in the replicated storage
Here is what myModule could look like:
local module = {}
module.myVariable = 2
module.myVariable2 = "this is a string"
function module.printMyVariables()
print(myVariable, myVariable2)
end
return module
In a normal script, I could require() my module script and use all the variables and functions inside of it:
local myModule = require(game:GetService("ReplicatedStorage").myModule)
myModule.printMyVariables()
print(myModule.myVariable, myModule.myVariable2)
Where you can read about modulescripts: https://developer.roblox.com/en-us/api-reference/class/ModuleScript
2 comments
_G are global variables that you can share between scripts. I don't know if people still use these now that we have Remotes and Modules. In this case _G.Data is a global table that is storing a players name as the Key, Upgrades as the subtable Key and the Value is the table of upgrades.
Yes I still use that, because module script have these utility and _G too. When I make a Database I use _G, when I make modes I use ModuleScript. ModuleScript isn't really the best to made a Database... Just to simplify the first real code that use _G lol. The big problem with a module is you need to found this. But a _G you just need to wait that let it be create by the owned variable script.