How to make a table inside of a table while a script is running?

So, I’m trying to make a table inside of another table while a script is running.

For an example:

local instances = {}
--wait a few seconds
-- script makes a new table inside of 'instances'
--in the new table, I insert part data that I need

Any methods to achieve this?

Still haven’t found a solution, any help is appreciated.

local instances = {}
instances["data"] = {}
instances["data"]["BrickColor"] = part.BrickColor

or you can use

instances[#instances+1] = {} -- Data in here
1 Like

I’ll try it real quick and see if it does anything.

I tested this little test code out and it runs fine.
Is this functional tho? (incase I’m doing something wrong and registers the same thing over and over)

local instances = {}
for i = 1,10 do
	instances["Frame"..i] = {}
	table.insert(instances["Frame"..i], game.Workspace.Baseplate)
	print(instances["Frame"..i][1].Name.." ("..i..")")
end

You are setting tem all to the baseplate

Yeah, I know. Let me try configuring it a bit to give it more complexity.

To explain it a bit more, I’m trying to make a replay module - so I’m trying to get every frame from RenderStepped to create tables for each individual part along with its properties.

I don’t know how efficient that would be. You could try just saving the player positions at different times and using Humanoid:Move()

Storing a table with the properties of everything every frame would cause a lot of lag and take a long time, I assume anyways

1 Like

Fully aware of that, but it would just replay the character’s movement - not collect informations from the entire map.

Yeah, but I’m trying to track arm/tool movement as well.

Okay, so. I’m using this little experiment code to see if it would print out stuff properly, but I landed on an error - “Line 10: attempt to call a number value”

Code:

local instances = {}
for i = 1,10 do
	instances["Frame"..i] = {}
	table.insert(instances["Frame"..i], game.Workspace.Baseplate.Transparency)
	game.Workspace.Baseplate.Transparency = game.Workspace.Baseplate.Transparency + 0.1
	wait(0.5)
end

for i = 1,10 do
print(instances["Frame"..i][1]" (frame "..i..")")
end

What line are you getting the error on?

10, was just about to add that to the previous comment.

print(instances["Frame"..i][1].." (frame "..i..")")

Forgot to join them

An easier way to loop the table would be the following:

for i,v in pairs(instances) do
    print(i, v[1])
end
1 Like

Oh, yeah. Totally forgot about that. Let me try it now.

Yeah, it works perfectly fine. Thanks for helping out! :grinning:

I’ll take your suggestions from above as well and try to not overload the game. I haven’t started on the code just yet.

1 Like