game.Players.PlayerRemoving:connect(function(p)
    p:WaitForDataReady()
    for i,v in pairs(game.Workspace:GetChildren()) do
		local name = string.sub(v.Name,1, 5)
		if name == "House" then
			local owner = v:FindFirstChild("Owner")
			local furniture = v:FindFirstChild("Furniture")
			if owner and furniture and furniture.ClassName == "Model" then
				if owner.Value == p.Name then
					local house = furniture
					p:SaveInstance(p.userId.."-House", house)
				end
			end
		end
	end

This saves the player's furniture in their house

script.Parent.Touched:connect(function(Part)
	if script.Parent.Parent.Parent.Owner.Value == "None" then
		local humanoid = Part.Parent:FindFirstChild("Humanoid")
		if humanoid then
			local plr = game.Players:GetPlayerFromCharacter(Part.Parent)
			if plr then
				if plr.Tycoon.Value == "None" then
					plr.House.Value = script.Parent.Parent.Parent.Name
					script.Parent.Parent.Parent.Owner.Value = plr.Name
					local oldfurn = script.Parent.Parent.Parent:FindFirstChild("Furniture")
					if oldfurn then
						oldfurn:Destroy()
					end
					
					local newfurn = game.ReplicatedStorage.Furniture:Clone()
					newfurn.Parent = script.Parent.Parent.Parent
					newfurn:SetPrimaryPartCFrame(script.Parent.Parent.Parent.Floor.CFrame)
					plr:WaitForDataReady()
   				    local house = plr:LoadInstance(plr.userId.."-HouseSave")
   				    house.Parent = script.Parent.Parent.Parent
					house:SetPrimaryPartCFrame(script.Parent.Parent.Parent.Floor.CFrame)
				end
			end
		end
	end
end)

And this loads it. When it loads I get the error message that it can't find "house" so I don't know if it's not saving correctly or if it's not loading correctly. This is a model it's supposed to be saving + loading (Which data persistence can do)

4 comments

0

Why are you using data persistance instead of data stores?

0

So that I can save Instances...

0

Don't use Data Persistence. Use Data Store.

0

I need to save instances. I can't use Data Store for that. Read the question before commenting.