Recently, I’ve been trying to work on my build in my building game, but it hasn’t been saving anything. Not even destroying blocks.
I first thought it was because the datastore hit the limit, but even destroying blocks didn’t save.
I then tried putting it in a bind to close, but still, no saving.
If you know the issue, please let me know!
function saveData(player: Player)
local islandFolder = workspace:FindFirstChild(player.UserId .. "_Island")
local totalBlocks = #islandFolder.Blocks:GetChildren()
local batchSize = 200
local index = 0
if islandFolder then
local blocks = {}
for _, block in pairs(islandFolder.Blocks:GetChildren()) do
index += 1
local blockData = {
Position = Utils.vec3ToTable(block.PrimaryPart.Position),
Rotation = Utils.CFrameAnglesToTable(block.PrimaryPart.Orientation),
Type = block.Name
}
table.insert(blocks, blockData)
block:Destroy()
if index % batchSize == 0 or index == totalBlocks then
task.wait(0.1)
end
end
local ok, err = pcall(PlayerState.Set(player, "Island", blocks))
if not ok then
warn(err)
end
islandFolder:Destroy()
end
playerLocationStore:RemoveAsync(tostring(player.UserId))
publicIslandsMap:RemoveAsync(tostring(player.UserId))
end
If none of the previous solutions work, then the problem might rely somewhere else from this code.
Assuming that you’ve used pcall with the right arguments, your statements are actually being executed (e.g. check using breakpoints, is the IF statement executed?,etc…), there’s no logical errors (e.g. islandFolder.Blocks actually has blocks inside of it), and you’re not negatively interfering with the internal datastore setup by PlayerState, then I can only guess it’s something else we can’t see here.
But I assume this was previously working? (seems like you have data already saved)