local DataStore = game:GetService("DataStoreService")
local ds = DataStore:GetDataStore("hellomynameijks45346345")
game.Players.PlayerAdded:connect(function(plr)
a = Instance.new("Folder", plr)
a.Name = "leaderstats"
Vals = ds:GetAsync(plr.UserId)
print(Vals)
if Vals then
for i, v in pairs(game.ReplicatedStorage.Values:GetChildren()) do
print(v)
Found = game.ReplicatedStorage.Values:FindFirstChild(v.Name)
print("yes")
if Found then
print("Found")
end
end
end
end)
game.Players.PlayerRemoving:connect(function(plr)
Vals = {}
for i, v in pairs(plr.leaderstats:GetChildren()) do
print(v.Name)
if v then
table.insert(Vals, v.Name)
end
end
ds:SetAsync(plr.UserId,Vals)
end)
I can't find the problem, when I leave the game, it prints the variable that was in my leaderstats. But when I then enter the game, the GetAsync return nil to Vals. Anyone know why?
