Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Saving Instances with datastore?

Is it possible to save parts with datastores? if so how, I've been looking high and low and I haven't been able to find anything. Could someone help me out please, Thanks in advance :)

1 answer

✓ Accepted answer

Hey there derfvb123,

No. You cannot save instances in DataStore. The DataStore manual explicitly states that you cannot do so. You can, however, save data about the parts that you want to save. Like so:

local Part			= path.To.Part
local DataStore	= game:GetService("DataStoreService"):GetDataStore("PartData")

local PartData	= {
	Position	= { Part.CFrame:components() };
	Color	= Part.BrickColor.Name;
	-- ... other properties...
}

DataStore:SetAsync("PartOne", PartData)

To render the part again, you would do the following:

local function RenderPart(partData)
	local part = Instance.new("Part", game.Workspace)

	part.CFrame	= CFrame.new(unpack(partData.Position))
	part.BrickColor	= BrickColor.new(partData.Color)
	
	-- Other setup...
end

local partData = DataStore:GetAsync("PartOne")

RenderPart(partData)

I'll leave the rest to your imagination (and ingenuity.) Have a nice day derfvb123, and best of luck with your project!

Warm regards,

tkcmdr

Sources:

CFrame API Page

BrickColor API Page

DataStoreService API Page

Global namespace/Basic functions

1 comment

0

If this explanation helped you solve your problem, don't forget to mark your question as answered, bud! Thank you for using Scripting Helpers, have a nice day! c;

This discussion is preserved as it was. New answers, comments, and votes are closed.