How to save and load models?

Hi, I am trying to save the value “Have”, if it is true then I just search for the model name in server storage and I load it, but my script does not work, it does not print in my function and does not even give errors. I have been trying to do this for a very long time, can someone help? I don’t even need to record their position, color, and so on, just clone if true.

My code -

local Model = game.Workspace:WaitForChild("Model")
local DataStore2 = require(1936396537)
DataStore2.Combine("DATA", "Have")

game.Players.PlayerAdded:Connect(function(Player)
	local HaveStore = DataStore2("Have", Player)
	
	local function SaveModels()
		for i, v in pairs(Model:GetChildren()) do
			Have = v:FindFirstChild("Have")
			HaveStore:Set(Have.Value)
			print(Have.Name)
			if Have.Value == true then
				local ClonedModel = game.ServerStorage:FindFirstChild(Have.Parent.Name):Clone()
				ClonedModel.Parent = game.Workspace
			end
		end
	end
	SaveModels()
	Have.Value = HaveStore:Get(false)
	
	Model.ChildAdded:Connect(function()
		SaveModels()
	end)
end)

If I understand correctly, you’re using DataStore2 to save the “Have” datastore? Which the value of Have is a bool (true or false)? If so, there are a few things you’re missing.

local Model = workspace:WaitForChild("Model") -- game.Workspace works to
local DataStore2 = require(1936396537)

game.Players.PlayerAdded:Connect(function(Player)
    local MainData = DataStore2.Combine("DATA", "Have")
    local HaveStore = DataStore2("Have", Player)
    local Have = Instance.new("BoolValue", Player)
    Have.Name = "Have"
    
    -- Update function
    local function UpdateHave(UpdatedValue)
        Have.Value = HaveStore:Get(UpdatedValue)
    end

    UpdateHave(false) -- false being the default value
    HaveStore:OnUpdate(UpdateHave) -- :OnUpdate will fire the UpdateHave function

    local function SaveModels()
        for i, v in pairs(Model:GetChildren()) do
            if Have.Value then
                local ClonedModel = game.ServerStorage:WaitForChild(v.Name):Clone()
                ClonedModel.Parent = workspace
            end
        end
    end
    SaveModels()
    Model.ChildAdded:Connect(SaveModels)
end)

Now if you’re trying to do this with multiple models, you’d want to use a table/dictionary to save your models. More information on DataStore2’s API can be found here.
I may have misunderstood what you’re asking, if so correct me

I’m sorry that I can’t answer you if it helped me, I will answer you when I have the morning.

You can’t really store instances, store a number that represents the model or something familiar.

I have 3 Parts in workspace, each of them contains the value have, if true, then it is saved and when the player comes in, the value that was set to true will be local PartName = have.parent then local cloned part = game. serverstorage:FindFirstChild(PartName.Name):Clone() (I don’t need to create anything)

Screenshot_1