I am storing block data and have come to a limit with this error: 502: API Services rejected request with error. Value length exceeded the allowed maximum. Value length was 272914 UTF8 bytes. Maximum allowed length is 262144 UTF8 bytes.
This is my script, I have tried limiting so many models to being stored in one datastore, still does not work.
local DSS = game:GetService("DataStoreService")
local modelDataStore = DSS:GetDataStore("e")
local modelDataStore2 = DSS:GetDataStore("e")
sniff = 1
game.ReplicatedStorage.Save.OnServerEvent:Connect(function(player)
game.Workspace.Check.Value = "Saving.."
local models = {}
for _, model in pairs(game.Workspace.Blocks:GetChildren()) do
local modelData = {}
local primaryPart = model.PrimaryPart
local position = model.PrimaryPart.Position
local direction = primaryPart.CFrame.lookVector
modelData.ModelName = model.Name
modelData.Position = {position.X, position.Y, position.Z, direction.X, direction.Y, direction.Z}
if #models > 999 then
sniff = 2
models[#models + 1] = modelData
print(models.ModelName)
else
print(100000*99999999999999)
sniff = 1
models[#models + 1] = modelData
print(models.ModelName)
end end
if sniff == 1 then
modelDataStore:SetAsync(player.UserId, models)
elseif sniff == 2 then
wait(1)
modelDataStore2:SetAsync(player.UserId, models)
end
print('done')
end)
thoughts? (that is my saving script, lmk if u need my loading script for some reason) Thanks, Jail.
(loading)
local DSS = game:GetService("DataStoreService")
local modelDataStore = DSS:GetDataStore("WelpWeAreAllDead")
local modelDataStore2 = DSS:GetDataStore("WelpWeAreAllDead2")
game.Players.PlayerAdded:Connect(function(player)
game.Workspace.plr.Value = player.Name
local models = modelDataStore:GetAsync(player.UserId)
local models2 = modelDataStore2:GetAsync(player.UserId.."_")
game.Workspace.Blocks:ClearAllChildren()
for _, modelData in pairs(models) do
local targetModel = modelData.ModelName
local information = modelData.Position
local variable = game.ReplicatedStorage:FindFirstChild(targetModel)
print(variable)
local newModel = variable:Clone()
local position = Vector3.new(information[1], information[2], information[3])
local lookVector = Vector3.new(information[4], information[5], information[6])
newModel:SetPrimaryPartCFrame(CFrame.new(position, position + (lookVector * 5)))
newModel.Parent = game.Workspace.Blocks
end
for _, modelData2 in pairs(models2) do
local targetModel2 = modelData2.ModelName
local information2 = modelData2.Position
local variable2 = game.ReplicatedStorage:FindFirstChild(targetModel2)
print(variable2)
local newModel2 = variable2:Clone()
local position2 = Vector3.new(information2[1], information2[2], information2[3])
local lookVector2 = Vector3.new(information2[4], information2[5], information2[6])
newModel2:SetPrimaryPartCFrame(CFrame.new(position2, position2 + (lookVector2 * 5)))
newModel2.Parent = game.Workspace.Blocks
end
end)

1 comment
This is amazing, just a lot to take in, mind helping me make it work with my loading script? (I edited it in on the question)