How would I use a Metatable for House Data?

Hi!
Recently, me and @6Marchy4 have been working on a House Building system.

We needed a way to store data on an item.
The answer - Metatables!

I set one up like this.

local Data = {
	DefaultData = {
		FlexPoints = 350,
		Plots = {	
			--Starter House Plot ID would go here, or items on the plot by default.
		},
		DefaultInventory = {
			--["item"] = {quantity = 7},
		}
	},
	DefaultItemData = {
		DisplayName = "N/A",
		Model = "N/A",
		CameraRotation = 0,
		WallItem = false,
		RoofItem = false,
		Price = 0,
		Description = "Not available, most likely to a game error.",
		Categories = "all",
		CanBePutInInventory = false
	},
	DefaultPlotData = {
		--[[
			Leave empty, will be filled automatically by the server.
			Example:
			["Item"] = {
				PositionPlaceholder = Vector3.new(0,0,0),
				RoationPlaceholder = 0
			}
		]]
	},
	["FurnitureCategories"] = {
		"All",
		"New",
		"Example",
	},
	
	["Imposter"] = {
		DisplayName = "Among Us Imposter",
		Model = "Impostor",
		CameraRotation = 0,
		WallItem = false,
		RoofItem = false,
		Price = 0,
		Categories = "all,new,fun",
		Description = "The SUSPoster is now in FYT2!  A fun little buddy to vent with.",
		CanBePutInInventory = true
	},
	
	
}

return Data

Now, I have a few questions.

A: How would I read the data from a script?
B: How would I set the data to be read?
Thanks!

2 Likes

Hmmm, have you tried putting it in a loop or like using the leaderboard stuff?

1 Like

No, as this is a table, that should be holding data, to be called.

setmetatable function or getmetatable function

3 Likes

You don’t really need a metatable for this. Unless you need any of the metamethods you don’t need metatables for this. Don’t over-complicate your code.

What would be a better way? It’s better than StringValues in a folder…