Datastore problem, can't save house

Hi, so I have a problem with my datastore, when ever I try to save a house instance, I keep on getting this error:


I’m not sure what exactly, this means and I’ve searched the error on dev forum, but most the solutions didn’t work for me. if anyone could tell me why this error and happening and how to fix it, it would greatly help!

Thanks a lot for reading!

Can you give us the code that’s saving the house into the data store? Also, are you using some custom data store module?

Yes, I can give you the code I’m using to save, also this is a datastore module I’ve made myself.

Can you show us the custom module aswell then?

Here’s the code you were asking for:

function PlayerTable.OnPlayerRemoving(Player)
	local PlayerData = SessionData[Player.UserId]
	if PlayerData then
		DataStore:UpdateAsync(Player.UserId, function(OldData)
			if PlayerData then
				return PlayerData
			elseif not PlayerData then
				return nil

Here’s whats inside the PlayerTable:

		Cash = 0,
		House = HousingModule.StarterHouse

Can you show us the custom module aswell then?

All the code in the module I made or the module instance? it’s 120 lines

Well only the part that actually saves stuff. Is it built on top of the default data store?

Yea, I just sent you the part that saves the stuff. Yes, it’s built on default datastore.

You cannot save Instances in a table, instead try using a string in replacement of HousingModule.StarterHouse so you can do HousingModule:FindFirstChild(House) in some other script that loads the house.

You can’t save Dictionaries or Instances, you will need to give an ID or Key to define each house with a string value and use an array, not a dictionary.

Instead of trying to save the actual house instance, which is impossible to do with datastore as it doesn’t allow you to store instances, you should instead save the house layout in some kind of way so you can rebuild it using that data you saved.

Adding to @Aspecky 's post, you can encode all the altered properties in a JSONEncoded table and later JSONDecode it and construct a new house using the table.

He can always use normal lua tables, unless there is a befinit to JSON tables that I don’t know of.

1 Like

JSONEncoded Tables are actually strings, so they are accepted in Roblox Datastores, but Roblox sometimes automatically converts tables to formattedData (idk whether it is JSON). However, this is kinda buggy so JSONEncoding is essentially just an extra precaution. :slightly_smiling_face: