game.Players.PlayerAdded:connect(function(player) local DataStore = game:GetService("DataStoreService") local leader = Instance.new("Folder",player) leader.Name = "leaderstats" for i,v in pairs(script:GetChildren()) do local d = DataStore:GetDataStore(v.Name) local x = Instance.new("NumberValue",leader) x.Name = v.Name x.Value = d:GetAsync(player.UserId) or v.Value end end) game.Players.PlayerRemoving:Connect(function(player) for i,v in pairs(script:GetChildren()) do print("Getting") local DataStore = game:GetService("DataStoreService") local d = DataStore:GetDataStore(v.Name) d:SetAsync(player.UserId, player.leaderstats[v.Name].Value) print("Saved") end end)
the intvalue for the stats was put inside the script
Closed as Not Constructive by JesseSong
This question has been closed because it is not constructive to others or the asker. Most commonly, questions that are requests with no attempt from the asker to solve their problem will fall into this category.
Why was this question closed?