I want to save a table as a datastore that has many other tables inside it, but how do I?
For a visual example, I want it to be like:
local DataToSave = {PlayerStats = {logs = 25}, Items = {'Axe', 'Sword'}}
This is the code I have right now but it has an underline under the word PlayerStats line 17 saying PlayerStats is an unknown global, how do I access the table inside that table without it showing unknown global so I can set the value of 'logs' to the value inside the PlayerStats table?
local DataStore = game:GetService("DataStoreService"):GetDataStore('PlayerStats')
game.Players.PlayerAdded:Connect(function(Player)
local leaderstats = Instance.new('Folder')
leaderstats.Parent = Player
leaderstats.Name = 'leaderstats'
local logs = Instance.new('IntValue')
logs.Parent = leaderstats
logs.Name = 'Logs'
local scope = 'player_' .. Player.UserId
local savedLogs = DataStore:GetAsync(scope)
if savedLogs then
logs.Value = savedLogs[PlayerStats]
end
end)
