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

How do i save a model with parts that have new decals/colors?

Asked by 5 years ago
Edited 5 years ago

I know i asked this before but i still dont get it.

so im working for a game that has a saving system. the only problem is that i dont know how to convert the saved object back, and i dont know how to save a decal inside a part.

my attempt (script used from zblox164 but i modified it a bit):

saving:

local m = game:GetService("DataStoreService")
local models = m:GetDataStore("model")
local parts = m:GetDataStore("parts")
script.Parent.OnServerEvent:Connect(function(plr,themodel)

local models = {}

for i, obj in pairs(themodel:GetChildren()) do
    if obj then
        table.insert(models, {
            ["Name"] = obj.Name;
                ["X"] = obj.Position.X;
                ["Y"] = obj.Position.Y;
                ["Z"] = obj.Position.Z;
                ["ClassName"] = obj.ClassName;
})
    end
end
parts:SetAsync(plr.UserId, models)
end)

loading:

local m = game:GetService("DataStoreService")
local datastore = m:GetDataStore("parts")

script.Parent.OnServerEvent:Connect(function(plr)
    local Saved = datastore:GetAsync(plr.UserId) or {}
    if Saved then
    for i, obj in pairs(Saved) do
        if obj then
    local partxd = Saved.ClassName
            local SavedModel = Instance.new("Model")
            local partlmao = Instance.new(partxd)

                    partlmao.CFrame = CFrame.new(0,0,0)
                    partlmao.Parent = SavedModel

                SavedModel.Parent = workspace
            end         
        end  
    end     
end)

I dont know if im in the right place.

Answer this question