Capture current state of workspace?

Basically, I’m attempting to capture the entire current state of the workspace at any given time of course.
For example, if lets say, an object is being flung into space, after 2 seconds, the state/positions/cframe/size of all the objects will be captured.

It would then be called back at any time afterwards into the same location.

What would be the best way to do this?

I was thinking of shoving every object cframe/size into a table but doing that constantly sounds like a good way for optimization horror. Any tips?

I don’t believe there’s a much better way to do this than what you mentioned, but one way to massively optimize from the start is to ignore all static parts and only store/revert the properties of parts that can move.

Ah, a shame, that might foil my plans a tad bit :thinking:
Regardless, since that covers that, what would be the best way to get and set the locations of the parts (even with the same name/type)?

I’m basically trying to create a timelapse sort of plugin.

Can’t seem to wrap my head around it though with regards to differentiating the parts from one another and still setting them via the locations in the table.

You can use a dictionary instead of a table, which is very similar but instead of numbered indexes you can use the parts as indexes. This allows you keep track of identical parts with different positions. Your code should have functions similar to this:

local revertParts = -- however you get all of the parts to revert
local lastState = { --[[
	[part] = CFrame;
--]]}

local function setPartsLocation() -- save where the parts should be on the next revert
	lastState = {}
	for index, part in pairs(revertParts) do
		lastState[part] = part.CFrame
	end
end

local function revertPartsLocation() -- revert all stored parts to their previous CFrame's
	for part, cframe in pairs(lastState) do
		part.CFrame = cframe
	end
end

The best way would be to take all of the core properties main ones being, classtype, name, color, cframe, size, cancolllide and transparency.

This means you can more or less litterally save and load parts.

function SavePart(P)-- did pass p as part but devforum said no
local prop = {P.ClassType,P.Name,P.CFrame} – and so on
end

function LoadPart(prop)
local NewP = instance.new(prop[1])
NewP.Name = prop[2]