Saving Module scripts to datastore?

I made a shop with module scripts where it has the values brought for each weapon inside the module scripts, and I want to be able to save it.

The problem is I can’t find any where how I can save a module script that has tables.

I have checked datastore page on developer hub, I looked for it on youtube cant find it. Now I HAVE heard I can try http JSONEncode, but I think there is a better way of saving instead of using Http service.

Heres the module below.

local module = {
	classic = {
		Name = "Classic Sword",
		brought = true
	},
	Ice = {
		Name = "Ice Sword",
		brought = false
	},
	EightBitSword = {
		Name = "8-Bit Sword",
		brought = false
	},
	Default_Knife = {
		Name = "Default Knife",
		brought = false
	},
	Kings = {
		Name = "Kings Knife",
		brought = false
	},
	Golden_Knife = {
		Name = "Golden Knife",
		brought = false
	},
	Gods_Sword = {
		Name = "Gods Sword",
		brought = false
	},
	Black = {
		Name = "Black Matter Knife",
		brought = false
	},
	Universe = {
		Name = "Universe Knife",
		brought = false
	},
	Atom = {
		Name = "Atomic Knife",
		brought = false
	},
	Atomic = {
		Name  = "Atomic Sword",
		brought = false
	},
	Nature = {
		Name  = "Nature Sword",
		brought = false
	},
	Setrex = {
		Name  = "Setrex Sword",
		brought = false
	}
}

return module
1 Like

You cannot save modulescripts, or any instances for that matter, to a datastore.

You should be able to call JSONEncode on a table in order to convert it to a string, which can be saved to a datastore. If you are unable to do this with the required module, try putting the shop in another table (ie. module.shop = {classic...}, and JSONEncode that instead.

1 Like

Thats exactly what i was thinking, but now atleast I know there IS NO other way, thanks mate :smiley:

1 Like