Hello, I'm trying to figure out how to save models and load them for later (in-game). I've been told this is possible by saving the properties of the model's children, but I don't know how to do that. Can anyone help? Here's my code (uses data persistence, which is deprecated).
script.Parent.MouseButton1Click:connect(function() if game.Players.LocalPlayer.DataReady == true then local house = game.ReplicatedStorage.AverageHouse:Clone() house.Parent = workspace game.Players.LocalPlayer:SaveInstance("House", house) game.Players.LocalPlayer.PlayerGui.HouseGUI:Destroy() else print("wait") end end)
You cannot save instances with datastores, you CAN save it through data persistence(You probably shouldn't do this though.) I'll show you how to save parts but through a table!
local part = workspace.Part1 local ds = game:GetService("DataStoreService"):GetDataStore("Part") part_properties = { ["Name"] = part.Name ["Position"] = part.Position ["Anchored"] = part.Anchored ["Parent"] = part.Parent } --Do the rest ds:SetAsync("Part1", part_properties) local dstable = ds:GetAsync("Part1") local part2 = Instance.new("Part", dstable["Parent"]) part2.Name = dstable["Name"] --Do the rest
Hope it helps!