Doesn't save/load the data. I save them with a loop, is that the problem?(I haven't used Data Stores in the past)
local datastore = game:GetService("DataStoreService"):GetDataStore("PlayerStats")
game.Players.PlayerAdded:connect(function(plr)
plr:WaitForDataReady()
Model = Instance.new("Model", plr)
Model.Name = "Values"
plr:WaitForChild("Values")
Ruby = Instance.new("IntValue")
Ruby.Name = "Ruby"
Ruby.Parent = plr.Values
GrumpDwarf1 = Instance.new("BoolValue")
GrumpDwarf1.Name = "GrumpDwarf1"
GrumpDwarf1.Parent = plr.Values
wait(2)
print("Cool")
local stats2 = plr:FindFirstChild("Values"):GetChildren()
for i = 1, #stats2 do
stats2[i].Value = datastore:GetAsync(stats2[i].Value)
end
end)
game.Players.PlayerRemoving:connect(function(player)
player:WaitForDataReady()
wait(2)
local stats = player:FindFirstChild("Values"):GetChildren()
for i = 1, #stats do
print(stats[i].Name)
datastore:SetAsync(stats[i].Name, stats[i].Value)
end
end)
|