I want this for the game me and the rest of the team are making, packing all the data in one single table and saving it then when unpacking i don’t think that’s the best way to do it.
local DataStore = game:GetService("DataStoreService"):GetDataStore("DataStore1")
game.Players.PlayerAdded:Connect(function(player)
-- Main Player Data folder --
local Main = Instance.new("Folder", player)
Main.Name = "PlayerData"
local Folder1 = Instance.new("Folder", Main)
Folder1.Name = "Currencies"
local Folder2 = Instance.new("Folder", Main)
Folder2.Name = "Inventory"
local Folder3 = Instance.new("Folder", Main)
Folder3.Name = "Hotbar"
local Folder4 = Instance.new("Folder", Main)
Folder4.Name = "Equipment"
local currency1 = Instance.new("IntValue", Folder1)
currency1.Name = "goldcoins"
currency1.Value = 0
local currency2 = Instance.new("IntValue", Folder1)
currency2.Name = "magicshards"
currency2.Value = 0
local SavedData = DataStore:GetAsync(player.userId)
if SavedData ~= nil then
local Currencies = SavedData[1]
currency1.Value = Currencies[1]
currency2.Value = Currencies[2]
end
end)
game.Players.PlayerRemoving:Connect(function(player)
local Currencies =
{player.PlayerData.Currencies.goldcoins,
player.PlayerData.Currencies.magicshards}
local Inventory = {}
local Hotbar = {}
local Equipment = {}
local Data = {Currencies, Inventory, Hotbar, Equipment}
DataStore:SetAsync(player.userId, Data)
end)
Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.