So I'm trying to save the player's stats and their parts in game. Alone the part saving works but when I added the stat saving it broke and didn't run the part saving.
local PartStoring = game:GetService("DataStoreService"):GetDataStore("BetaParts")
local StatStoring = game:GetService("DataStoreService"):GetDataStore("BetaStats")
--//Variables
local placingStorage = game.ServerStorage.PlaceableParts
--//Tables
local statHolder = {}
game.Players.PlayerRemoving:connect(function(player)
if game.Workspace:FindFirstChild(player.Name.."'sItems") then
print('hello is me fruim d a uder si de') --Prints
local key = "user_"..player.userId
--Stats Storing
local Stats
for k,l in pairs (statHolder) do
if l[1] == player.Name and l[2] then
Stats = l
end
end
print('mid check') --Prints
if Stats then
StatStoring:SetAsync(key,Stats[2])
table.remove(Stats)
end
--Part Storing
print('saving parts') --Doesn't print
local model = game.Workspace[player.Name.."'sItems"]
local FinalString = {}
for i,v in pairs (model:GetChildren()) do
x,y,z,rx,ry,rz = v.PrimaryPart.CFrame.X, v.PrimaryPart.CFrame.Y, v.PrimaryPart.CFrame.Z, v.PrimaryPart.CFrame:toEulerAnglesXYZ()
local comp = {x,y,z,rx,ry,rz}
local everything = {v.Name,comp}
if model:FindFirstChild("Settings") then
for k,l in pairs (model.Settings:GetChildren()) do
table.insert(everything,10000,l.Name)
table.insert(everything,10000,l.Value)
end
end
table.insert(FinalString,everything)
end
if #FinalString >= 1 then
print('saved') --of course doesn't print
PartStoring:SetAsync(key, FinalString)
end
end
end)

2 comments
Perhaps SetAsync is hanging. But that's odd, because it's supposed to be async...
The weird thing is that I'm not really new to DataStores at all, this is just random.