Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How would I write the load part of this datastore?

Asked by 7 years ago

I have datastore for my saving placed models but i'm not sure how to load it back when the player joins the game. Below is when player leaves.

local DataStoreService = game:GetService("DataStoreService")
local DS = DataStoreService:GetDataStore("Basedata")

game.Players.PlayerRemoving:connect(function(p)

local basedata = {}
for i,y in pairs(game.Workspace.Placed:GetChildren()) do
local tab = {
y.Name ,
y.PrimaryPart.Position.X,
y.PrimaryPart.Position.Y,
y.PrimaryPart.Position.Z,
y.PrimaryPart.Rotation.X,
y.PrimaryPart .Rotation.Y,
y.PrimaryPart.Rotation.Z
}
table.insert(basedata,tab)

DS:SetAsync(tostring(p.UserId).."Basedata",basedata)

print ('done')

end
end)

Answer this question