THIS IS NOT A REQUEST SITE BUT I WILL TRY TO HELP YOU OUT:
You can't save models directly. To save them you need to save their properties such as the name, position and or color (you could also save any decals on them).
You will need to understand PrimaryParts before doing this.
What I do is loop through the place where the models are located then insert the needed properties into a special array called a dictionary and save that. Here is an example:
local models = locationWhereModelsAre
local array = {}
for i, obj in pairs(models:GetChildren()) do
if obj then
table.insert(array, {
["Name"] = obj.Name;
["Pos"] = {
["X"] = obj.PrimaryPart.CFrame.X;
["Y"] = obj.PrimaryPart.CFrame.Y;
["Z"] = obj.PrimaryPart.CFrame.Z;
["R"] = obj.PrimaryPart.Orientation.Y
}
)}
end
end
To load the model in all you need to do is have a place to access the model such as ReplicatedStorage and a basic understanding of DataStore's. Since scripts run top to bottom you can search through the models and check if the name matches the saved one. Then you can give it the position and rotation and anything else you might need. Here is an example of the load system:
if Saved then
for i, obj in pairs(Saved) do
if obj then
local SavedModel = game.ReplicatedStorage.Models:FindFirstChild(obj.Name)
if SavedModel then
local Model = SavedModel:Clone()
if Model then
Model:SetPrimaryPartCFrame(CFrame.new(Saved.Pos.X, Saved.Pos.Y, Saved.Pos.Z) * CFrame.Angles(0, math.rad(Saved.Pos.R), 0))
end
Model.Parent = workspace
end
end
end
else
Save(plr)
end
That code will not work but with some editing it would work fine. Thats how I do it. Hope this helps!
7 comments
I believe it is impossible to save models in the data store
Try to make a datastore using the model and getting the children of the model.
You cannot save objects (Userdata) in datastores. Your best shot is saving the values of the properties like position, color, etc. Thus, you would have to write a function that loops through the model and saves either a string or a table of data relating to each child. Then, when you load the object from the datastore, you would have a function to convert it back.
How much datastore do i need? (getdatastore). Do i need one or a ton?
also what do you mean by converting it back? do i need to do Instance.new?
You can use one datastore. As for converting it back, yes, you would have to recreate all of the instances and then change their properties to those that you saved.
what do i need to "setasync"? there are too many parts, so how do i get the correct table?