Save your player data with ProfileService! (DataStore Module)

I suggest packing Profile.Data as a member of another table:

local player_data = {
   Save = Profile.Data,
   Session = {
      YourTemporaryData = 1,
   }
}
-- This way you create a single variable containing both savable and temporary data

In case you didn’t know, tables are assigned to variables as references and assigning other variables to your table will only clone the reference, but all variables with that reference will point to the same, uncloned, table.

local t = {}
local t_ref = t -- This will not deep-copy a table;

t_ref.Value = 1 -- "t_ref" and "t" point to the same exact table
print(t.Value) --> 1

Lua documentation:
https://www.lua.org/pil/2.5.html

3 Likes