I have been trying to do Data Stores for already a week and nothing is working.
AND NO, THE WIKI DID NOT HELP.
I have 2 scripts, one to save and one to load.
Here's the one to load:
game.Players.PlayerAdded:connect(function(player) print("Getting player information..") local datastore = game:GetService("DataStoreService"):GetDataStore(player.Name.."Stats") wait(15) print("Player information loaded succesfully!") player:WaitForChild("leaderstats") wait(1) Instance.new("IntValue",player.Character:WaitForChild("PlayerSkins")) local stats = player.Character:WaitForChild("PlayerSkins"):GetChildren() print("Loading stats...") pcall(function() for i = 1, #stats do wait(1) stats[i].Value = datastore:GetAsync(stats[i].Name) stats[i].Name = datastore:GetAsync(stats[i].Value) print(stats[i].Name.." Given succesfully!") --Prints "0 Given succesfully" Why this happens? wait(.1) end print("Stats succesfully loaded!") end) end)
The script is in workspace.
It prints stuff INCORRECTLY (Prints that it loaded 0 for the name and value).
And then there's the one to load:
local player = game.Players:GetPlayerFromCharacter(script.Parent) repeat wait() until player.Character player.Character:WaitForChild("BoughtSkin").OnServerEvent:connect(function() print("Auto saving...") wait(2) local datastore = game:GetService("DataStoreService"):GetDataStore(player.Name.."Stats")--Player key local statstorage = player.Character:WaitForChild("PlayerSkins"):GetChildren() pcall(function() for i = 1, #statstorage do datastore:SetAsync(statstorage[i].Name, statstorage[i].Value) print(statstorage[i].Name.." Saved succesfully!") wait(.1) end print("Succesfully saved!") end) end)
The script is in "StarterCharacterScripts"
It prints the stuff correctly(Prints that it saved)
But when there is the time to load, it loads 0 in the name and 0 in the value,idk why
I don't know why it loads 0.. Can somebody help me? I REALLY need help and I would give my Sincere thanks to whoever helps me. Thank you. :(