^. I made a data store save multiple IntValues. Code:
local dataStore = game:GetService("DataStoreService")
local playerData = dataStore:GetDataStore("playerData")
game.Players.PlayerAdded:Connect(function(player)
print("Player Joined Game")
local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
leaderstats.Parent = player
local coins = Instance.new("IntValue")
coins.Name = "Coins"
coins.Parent = leaderstats
local wins = Instance.new("IntValue")
wins.Name = "Wins"
wins.Parent = leaderstats
local ID = "Player: " .. player.UserId
local data = playerData:GetAsync(ID)
if data then
coins.Value = data["Coins"]
wins.Value = data["Wins"]
else
coins.Value = 0
wins.Value = 0
end
end)
game.Players.PlayerRemoving:Connect(function(player)
print("Player Left Game")
local ID = "Player: " .. player.UserId
local data = {
player.leaderstats.Coins.Value;
player.leaderstats.Wins.Value
}
local success,err = pcall(function()
print("In Protected-Call Function")
playerData:SetAsync(ID, data)
end)
if not success then
warn("Couldn't Save Your Data! ): ")
else
print("Successfully Saved Your Data!! :) ")
end
end)
It’s printing what it’s supposed to, but not saving data. No errors in the output. I published it, then I played in the actual game. I turned on studio access to api services. Thanks!