I have this DataStore script I followed a tutorial for a long time ago, and I want to make it simpler to use. Specifically to add more types of resources I want to save. That's all, thanks!
local module = {}
local DataStore = game:GetService("DataStoreService"):GetDataStore("gameyall232")
local StartingMoney = 500
game.Players.PlayerAdded:connect(function(plr)
local Stats = Instance.new("Folder", plr)
Stats.Name = "Stats"
local Money = Instance.new("NumberValue", Stats)
Money.Name = "Money"
Money.Value = StartingMoney
local SavedMoney = DataStore:GetAsync(plr.userId.."-Money")
if SavedMoney ~= nil then
Money.Value = SavedMoney
end
end)
game.Players.PlayerRemoving:connect(function(plr)
local id = plr.userId
local MoneyValue = plr.Stats.Money.Value
DataStore:SetAsync(id.."-Money", MoneyValue)
end)
return module
