I have a problem with saving in datastore. So basically i have followed a tutorial on youtube. so here’s the sample of script that i got
local DataStoreService = game:GetService("DataStoreService")
local myDataStore = DataStoreService:GetDataStore("DataStores")
game.Players.PlayerAdded:Connect(function(player)
local Id = "Player_"..player.UserId
local uang = player.leaderstats.Uang
local makan = player.leaderstats.Makan
local data
local success, errormessage = pcall(function()
data = myDataStore:GetAsync(Id)
end)
if success then
-- Set data
uang.Value = data.uang
makan.Value = data.makan
end
end)
game.Players.PlayerRemoving:Connect(function(player)
local Id = "Player_"..player.UserId
local data = {
uang = leaderstats.Uang.Value;
makan = leaderstats.Makan.Value;
}
local success, errormessage = pcall(function()
myDataStore:SetAsync(Id, data)
end)
end)
My question is how to save a lot of data, because i need to wrote the data manually. Or is there any technique to make it simpler ?