I'm making a game that requires saving building information, and I wrote 4 functions that can save the data in tables. However, whenever I try to save it, it says that I "can't save an array in a datastore", even though I'm pretty sure it's a table...? I'm not even sure what the difference between an array and a table is. Any help is appreciated. Here are the functions:
function getData(thing,basepos)
if thing.ClassName == "Model" then
return {thing.PrimaryPart.Position-basepos,thing.PrimaryPart.Orientation,thing.Name}
elseif thing.ClassName == "Part" or thing.ClassName == "MeshPart" or thing.ClassName == "SeatPart" then
return {thing.Position-basepos,thing.Orientation,thing.Name}
end
end
function getAllData(model,basepos)
local alldata = {}
for i = 1, #model:GetChildren() do
local current = model:GetChildren()[i]
local currentData = getData(current,basepos)
alldata[i] = currentData
end
return(alldata)
end
function getModelFromData(data,basepos)
local pos = data[1]
local orientation = data[2]
local name = data[3]
local newModel = game.ReplicatedStorage[name]:Clone()
if newModel.ClassName == "Model" then
newModel:SetPrimaryPartCFrame(CFrame.new(pos,orientation))
elseif newModel.ClassName == "Part" or newModel.ClassName == "SeatPart" or newModel.ClassName == "MeshPart" then
newModel.Position = pos+basepos
newModel.Orientation = orientation
end
return newModel
end
function getModelFromAllData(allData,modelName,basepos)
local thisModel = Instance.new("Model")
thisModel.Name = modelName
for i=1, #allData do
local currentData = allData[i]
local currentmodel = getModelFromData(currentData,basepos)
currentmodel.Parent = thisModel
end
return thisModel
end

1 comment
Is access to external api on?