So there's StringValues, which hold strings, IntValues, which hold Integers, etc...
But are there any type of values that hold Tables?
No, there is not.
You can store values in _G
, the global table, an object that all Scripts have the same reference to, though these won't be replicated to clients (LocalScripts), or between them.
-- _G Example: -- Script 1 while true do wait() _G.cat = {jumping = math.random(1,2) == 1} end -- Script 2 while not _G.cat do wait() -- Wait for the first Script to set up end while true do wait() print( _G.cat.jumping ) -- randomly changing true and false printout end
In general, using _G
isn't very elegant of a solution.
One option is to substitute this with a reference provided by a ModuleScript.
Another way to do something equivalently is to use RemoteFunctions / BindableFunctions to provide an API to read arbitrary data, structured however you designed.
I want to somehow access the table of winners in another script
In that case, it would make most sense to just use a BindableFunction (or one of the other more or less equivalent ones, like RemoteFunction or BindableEvent)
-- BindableFunction -- Script with `winners` table function game.RequestWinners.OnInvoke() return winners; end -- Other script needing the list of winners currently local theirWinners = game.RequestWinners:Invoke() -- (Where game.RequestWinners is a BindableFunction)
Though passing this value between scripts probably isn't the best thing to be done.
Probably, you can manage in just the one script.
If things like GUIs or other things need to respond (e.g., "YOU WON!") you only need to write a value to the person and say their place (i.e., just an IntValue); the GUI reads this single value and responds accordingly.
If each player's GUI wants to show the list of winners, the main script should do the same thing as before. This time, the GUI script will simply consult all of the players instead of just the one.
If for some reason processing those numbers is complicated (perhaps odd tie-breaking rules), you can either