So, I'm trying to make a DataStore and a Leaderstats script all in one, the script is a normal script in ServerScriptService
game.Players.PlayerAdded:connect(function(player) local key = "user_"..player.UserId local folder = Instance.new("Folder") folder.Parent = player folder.Name = "stores" local leaderstats = Instance.new("Folder") leaderstats.Parent = player leaderstats.Name = "leaderstats" local money = Instance.new("IntValue", player) money.Name = "Money" local lemon = Instance.new("IntValue") lemon.Parent = player.stores local dss = game:GetService("DataStoreService") local moneyds = dss:GetDataStore("money") moneyds:UpdateAsync(key, function(oldValue) if oldValue == 0 then local newValue = 0 newValue = newValue + 60 return newValue end end) money.Value = moneyds:GetAsync(key) end)
Sorry if this is completely wrong, it's been a while since I've done DataStores
I will fix that datastore part for yah!
game.Players.PlayerAdded:connect(function(player) local key = "user_"..player.UserId local folder = Instance.new("Folder") folder.Parent = player folder.Name = "stores" local leaderstats = Instance.new("Folder") leaderstats.Parent = player leaderstats.Name = "leaderstats" local money = Instance.new("IntValue", player) money.Name = "Money" local lemon = Instance.new("IntValue") lemon.Parent = player.stores local dss = game:GetService("DataStoreService") local moneyds = dss:GetDataStore("money") local moneyval = moneyds:GetAsync(key) or 60 money.Value = moneyval end)