Basically, I have a system that saves the player's data whenever they leave and loads it whenever they join. For some unknown reason, whenever a value is changed from the player's data, it fails to to get the player's data (GetAsync) and it doesn't move on to the next piece of code. This is strange behavior as I have never encountered it before, but this is the first time I'm saving all the player's data into one data store. I'm using a dictionary to save the player's data, and I'm loading their data into folders. Here's a snippet of the code that saves the player's data,
function SaveData(player)
print("Saving Data From "..player.Name)
local PlayerFolder = game.ReplicatedStorage["Player Data"]:FindFirstChild(player.Name.." Data")
local OriginalData = PrimaryData:GetAsync("user_"..player.UserId)
local TableData = HttpService:JSONDecode(OriginalData)
TableData.ClassType = PlayerFolder["Class Type"].Value
TableData.Tier = PlayerFolder["Tier Folder"].Tier.Value
TableData.Level = PlayerFolder["Tier Folder"].Level.Value
TableData.ArmorLevel = PlayerFolder["Armor Level"].Value
TableData.Wins = PlayerFolder.Statistics.Wins.Value
TableData.Losses = PlayerFolder.Statistics.Losses.Value
TableData.Kills = PlayerFolder.Statistics.Kills.Value
TableData.Deaths = PlayerFolder.Statistics.Deaths.Value
TableData.Coins = PlayerFolder.Coins.Value
TableData.Weapons = {}
for i,v in pairs(PlayerFolder["Weapons Folder"]:GetChildren()) do
if v:IsA("StringValue") then
table.insert(TableData.Weapons,v.Value)
end
end
local EncodedData = HttpService:JSONEncode(TableData)
print(EncodedData)
PrimaryData:SetAsync("user_"..player.UserId,EncodedData)
end
If you want to test this out yourself or you need more information, here's my whole piece of code,
--// Created by McRocketNuggets //--
--Variables--
local PlayersService = game:GetService("Players")
local PrimaryData = game:GetService("DataStoreService"):GetDataStore("PrimaryDatav5")
local PrimaryEvent = Instance.new("RemoteEvent",game.ReplicatedStorage)
PrimaryEvent.Name = "Primary Event"
local HttpService = game:GetService("HttpService")
--Functions--
function CreateDataFolders(player)
local CurrentData = PrimaryData:GetAsync("user_"..player.UserId)
local TableData = HttpService:JSONDecode(CurrentData)
local PlayerFolder = Instance.new("Folder",game.ReplicatedStorage["Player Data"])
PlayerFolder.Name = player.Name.." Data"
local ClassType = Instance.new("StringValue",PlayerFolder)
ClassType.Value = TableData.ClassType
ClassType.Name = "Class Type"
local TierFolder = Instance.new("Folder",PlayerFolder)
TierFolder.Name = "Tier Folder"
local Tier = Instance.new("StringValue",TierFolder)
Tier.Value = TableData.Tier
Tier.Name = "Tier"
local Level = Instance.new("NumberValue",TierFolder)
Level.Value = TableData.Level
Level.Name = "Level"
local ArmorLevel = Instance.new("NumberValue",PlayerFolder)
ArmorLevel.Value = TableData.ArmorLevel
ArmorLevel.Name = "Armor Level"
local StatsFolder = Instance.new("Folder",PlayerFolder)
StatsFolder.Name = "Statistics"
local Kills = Instance.new("NumberValue",StatsFolder)
Kills.Name = "Kills"
Kills.Value = TableData.Kills
local Deaths = Instance.new("NumberValue",StatsFolder)
Deaths.Name = "Deaths"
Deaths.Value = TableData.Deaths
local Wins = Instance.new("NumberValue",StatsFolder)
Wins.Name = "Wins"
Wins.Value = TableData.Wins
local Losses = Instance.new("NumberValue",StatsFolder)
Losses.Name = "Losses"
Losses.Value = TableData.Losses
local Cash = Instance.new("NumberValue",PlayerFolder)
Cash.Name = "Coins"
Cash.Value = TableData.Coins
local WeaponsFolder = Instance.new("Folder",PlayerFolder)
WeaponsFolder.Name = "Weapons Folder"
for i,v in pairs(TableData.Weapons) do
local visualItem = Instance.new("StringValue",WeaponsFolder)
visualItem.Name = v
visualItem.Value = v
end
end
function SaveData(player)
print("Saving Data From "..player.Name)
local PlayerFolder = game.ReplicatedStorage["Player Data"]:FindFirstChild(player.Name.." Data")
local OriginalData = PrimaryData:GetAsync("user_"..player.UserId)
local TableData = HttpService:JSONDecode(OriginalData)
TableData.ClassType = PlayerFolder["Class Type"].Value
TableData.Tier = PlayerFolder["Tier Folder"].Tier.Value
TableData.Level = PlayerFolder["Tier Folder"].Level.Value
TableData.ArmorLevel = PlayerFolder["Armor Level"].Value
TableData.Wins = PlayerFolder.Statistics.Wins.Value
TableData.Losses = PlayerFolder.Statistics.Losses.Value
TableData.Kills = PlayerFolder.Statistics.Kills.Value
TableData.Deaths = PlayerFolder.Statistics.Deaths.Value
TableData.Coins = PlayerFolder.Coins.Value
TableData.Weapons = {}
for i,v in pairs(PlayerFolder["Weapons Folder"]:GetChildren()) do
if v:IsA("StringValue") then
table.insert(TableData.Weapons,v.Value)
end
end
local EncodedData = HttpService:JSONEncode(TableData)
print(EncodedData)
PrimaryData:SetAsync("user_"..player.UserId,EncodedData)
end
function EventFired(player,topic,body,conclusion,...)
PrimaryEvent:FireClient(player,topic,body,conclusion,...)
end
function EventReceieved(player,topic,body,conclusion)
if topic == "[Insert topic]" then
--code
return
end
end
PrimaryEvent.OnServerEvent:Connect(EventReceieved)
PlayersService.PlayerAdded:Connect(function(player)
local CurrentPlayerData = PrimaryData:GetAsync("user_"..player.UserId)
if CurrentPlayerData == nil then
local Table = {
["PlayerId"] = player.UserId;
["ClassType"] = "N/A";
["Tier"] = "Bronze";
["Level"] = 4;
["ArmorLevel"] = 1;
["Weapons"] = {};
["Wins"] = 0;
["Losses"] = 0;
["Kills"] = 0;
["Deaths"] = 0;
["Coins"] = 0;
}
local JSONData = HttpService:JSONEncode(Table)
local NewData = PrimaryData:SetAsync("user_"..player.UserId,JSONData)
CreateDataFolders(player)
else
CreateDataFolders(player)
end
end)
PlayersService.PlayerRemoving:Connect(function(player)
SaveData(player)
end)
Thank you!

2 comments
It would be a great help to yourself and others if you indented your code. It can also help you spot problems before they arise. This is just a note not an answer
Sorry about that, it's been a habit of mine to format it similar to a novel.