So i am trying to make a saving system for models, but i dont know how. So how do i save models that have extra parts that were put from an remoteevent?
for ex. a player puts a random decal in an random part (every part is called part). and a player puts a new part to an model. how do isave that decal/part and then load it when the player joins?
I have not attempted to script it, because i dont know what i need/what to do.
thank you
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!
Closed as Not Constructive by Void_Frost, zblox164, DeceptiveCaster, and evaera
This question has been closed because it is not constructive to others or the asker. Most commonly, questions that are requests with no attempt from the asker to solve their problem will fall into this category.
Why was this question closed?