I'm making a place that will save multiple values and I was wondering if I could use an easier way for values?
local DataStore = game:GetService("DataStoreService") local ds = DataStore:GetDataStore("CashSaveSystem") game.Players.PlayerAdded:connect(function(player) local folder = Instance.new("Folder",player) folder.Name = "places" local stat = Instance.new("IntValue",folder) stat.Name = "first" stat.Value = ds:GetAsync(player.UserId) or 0 ds:SetAsync(player.UserId, stat.Value) stat.Changed:connect(function() ds:SetAsync(player.UserId, stat.Value) end) end) game.Players.PlayerRemoving:connect(function(player) ds:SetAsync(player.UserId, player.places.first.Value) end)
You can use an array to save all your data:
local DataStore = game:GetService("DataStoreService") local ds = DataStore:GetDataStore("CashSaveSystem") game.Players.PlayerAdded:connect(function(player) local d = ds:GetAsync(player.UserId) local folder = Instance.new("Folder",player) folder.Name = "places" local stat = Instance.new("IntValue",folder) stat.Name = "first" stat.Value = d[1] or 0 ds:SetAsync(player.UserId, stat.Value) stat.Changed:connect(function() ds:SetAsync(player.UserId, {stat.Value; 'Hi lol';) end) print(d[2]) end) game.Players.PlayerRemoving:connect(function(player) local tbl = {player.places.first.Value; 'Hi lol'} ds:SetAsync(player.UserId, player.places.first.Value) end)