Hey. Ive been wanting to make a grid placement sandbox tycoon, but im not sure how to save models locations in the base. What im mainly unsure of is how to save all the instances positions and load them all in one datastore, would i do it all in one table? how would i know how many objects are being loaded? Or am i overcomplicating this? Any help is appreciated, thanks!
Ive been given the idea of this script but through testing it doesnt seem to be working and comes up with no errors. Do i need to enable save place api?
DATA = game:GetService("DataStoreService"):GetDataStore("OINSDHLSJHG")
game.Players.PlayerAdded:connect(function(plr)
local t = Instance.new('StringValue')
t.Name = "Tycoon"
t.Parent = plr
if workspace["Tycoon A"].Owner.Value == "" then
local baseplate = workspace["Tycoon A"].Base
plr.Tycoon.Value = "Tycoon A"
workspace["Tycoon A"].Owner.Value = plr.Name
end
plr:WaitForDataReady()
if DATA:GetAsync(plr.userId) then
local models = DATA:GetAsync(plr.userId)
for _,v in pairs(models) do
if plr.Tycoon.Value ~= "" then
local baseplate = workspace:FindFirstChild(plr.Tycoon.Value).Base
local createdModel = game.ReplicatedStorage.Objects:FindFirstChild(v[1]):Clone()
local offset = Vector3.new(v[2][1],v[2][2],v[2][3])
createdModel:SetPrimaryPartCFrame(CFrame.new(baseplate.Position + offset))
print("Hello"..baseplate)
end
end
end
end)
game.Players.PlayerRemoving:connect(function(plr)
plr:WaitForDataReady()
if plr.Tycoon.Value ~= "" then
local tycoon = workspace:FindFirstChild(plr.Tycoon.Value)
local baseplate = tycoon:FindFirstChild("Base") --set to tycoon baseplate
local models = {}
for _,v in pairs(tycoon:GetChildren()) do
if v:IsA("Model") and v.PrimaryPart then
local offset = v.PrimaryPart.Position - baseplate.Position
table.insert(models,1,{v.Name,{offset.X,offset.Y,offset.Z}})
end
end
end
--save models table
end)
Thanks!

1 comment
Also i dont currently have a placement system made as i wont bother if i dont end up knowing how to save the thing :P