Try adding a local data = {}
variable at the start of the _L.Load
function and then change this
to this
local success,err = pcall(function()
data = BlocksDataStore:GetAsync(userid)
end)
Try adding a local data = {}
variable at the start of the _L.Load
function and then change this
to this
local success,err = pcall(function()
data = BlocksDataStore:GetAsync(userid)
end)
nope, it still doesn’t save the blocks
Can we see your current code now?
local _L = {}
local DataStoreService = game:GetService("DataStoreService")
local BlocksDataStore = DataStoreService:GetDataStore("BlocksDataStore")
function _L.Call()
game.Players.PlayerAdded:Connect(function(player)
_L.Load(player)
end)
game.Players.PlayerRemoving:Connect(function(player)
_L.Save(player)
end)
end
function _L.Load(player)
local playerBlocks = Instance.new("Folder", workspace)
playerBlocks.Name = tostring(player.Name).."_blocks"
local data = {}
local userid = player.UserId
local success,err = pcall(function()
data = BlocksDataStore:GetAsync(userid)
end)
if data then
for i, v in pairs(playerBlocks:GetChildren()) do
v.Parent = game[v.ParentN.Value]
v.Postion.X = data[v].PosX
v.Postion.Y = data[v].PosY
v.Postion.Z = data[v].PosZ
v.Orientation.X = data[v].OX
v.Orientation.Y = data[v].OY
v.Orientation.X = data[v].OZ
end
while true do
print(data)
wait(5)
end
end
end
function _L.Save(player)
local userid = player.UserId
local data = {}
game.ReplicatedStorage.Events.Add.Event:Connect(function(posX, posY, posZ, oY, oX, oZ)
table.insert(data, {PosX = posX, PosY = posY, PosZ = posZ, OX = oX, OY = oY, OZ = oZ})
end)
workspace:FindFirstChild(tostring(player.Name).."_blocks"):Destroy()
local success = pcall(function()
BlocksDataStore:SetAsync(userid, data)
end)
end
return _L
Try changing the table you save to an array because I don’t think datastores save dictionaries.