Hello, my name is xMonaitary and I am new to this website. I found out that this website is very helpful and decided to make my own acc here.
My question is: Would I be able to share datastores between two scripts using _G function?
local DataStore = game:GetService("DataStoreService") _G.PlayerData = Datastore:GetDataStore("Randomuserdatav1.1")`
To answer your question directly, yes. You can technically use _G. To answer the more important question of whether or not you *should,* not really.
First, any server script is allowed to check DataStore. You don't need _G for that (though you also shouldn't constantly send get requests or overwrite existing data, you'll get throttled.)
You should use module scripts. Use module scripts both to easily check and set data in the DataStore, and to have server-side variables that can be checked and modified from other scripts. _G isn't necessary here, and this isn't the best application for it. It's often regarded as a poor practice today. (A lazy solution is to use value objects, but I don't recommend them.)
You might be interested in the following pages:
These pages provide both examples and descriptions which should help you.