Ok so, what I'd like to do in my game is have ores/trees around the map that can be found. When mined/chopped, you get some XP and 1 of said ore/log added to your inventory, which is on the server in a datastore. You can use these ores on your weapon to customize the look of it. I'm struggling with adding the inventory. I know how data stores work. My problem is actually implementing the Objects. So if I wanted to randomize the chance of an ore spawning, I'd grab a table with all the ore names, so x = ["Ruby_Ore", "Sapphire_Ore", etc], how would I tell all the scripts that might need to use the ores system, that "Ruby_Ore" means Ruby? Sorry if my question is confusing because this is my first time asking for help with something, and I don't have many ideas on how I'd approach this problem. Thanks for any help.
✓ ANSWER ACCEPTED
How would I handle an ores system that all scripts understand, and link into a DataStore Inventory?
1 answer
✓ Accepted answer
You can use global tables. Example: Set the global
local Ores = {Ruby = "Ruby_Ore",Sapphire = "Sapphire_Ore"} -- etc
_G.Ores = Ores
From other script
-- example
for i,v in pairs(_G.Ores) do
-- i for index
-- v for value
-- in this case i would be Ruby Or Sapphire, the names
-- and v would be Ruby_Ore or Sapphire_Ore wich are the values set to them
print(""..i.." equals to "..v.."!")
end
Happy scripting!
This discussion is preserved as it was. New answers, comments, and votes are closed.

6 comments
Would I set this script from a Server Script? Or a Local? If I set it on the server, does it replicate to the Client?
Nope, Set it on server and client
Ah ok, thanks for your help!
python, if this helped, i would highly appreciate accepting my answer :D
Yep, I'm just figuring out how to now lol. Also, can I call a module script that is in ReplicatedStorage that sets the global?
If you call it from the client, it will be called and set a client global, if called by server will set a server global. Any actions they do depends from where you are calling them, In conclusion yes