Editing table help

functions:

funcs
function module:EquipTag(plr, name)
	local p = Profiles[plr]

	for _, JSONTag in pairs(p.Data.ChatTags) do 
		local tag = game:GetService("HttpService"):JSONDecode(JSONTag)
		
		if tag.Content == name then
			tag.Equiped = true
			print('Equipped')

			local newJSON = game:GetService("HttpService"):JSONEncode(tag)
			JSONTag = newJSON
			print("New JSONTag:", JSONTag)
			print("New profile", Profiles[plr])
			return
		end
	end
end

function module:UnequipTag(plr, name)
	local p = Profiles[plr]

	for _, JSONTag in pairs(p.Data.ChatTags) do 
		local tag = game:GetService("HttpService"):JSONDecode(JSONTag)
		
		if tag.Content == name then
			tag.Equiped = false
			print('Unequipped')

			local newJSON = game:GetService("HttpService"):JSONEncode(tag)
			JSONTag = newJSON
			print("New JSONTag:", JSONTag)
			print("New profile", Profiles[plr])
			return
		end
	end
end

output:


(highligted)
expected:
the profileservice profile is supposed to update to

Is there any reason why are you converting it into JSON string?

Because you can’t save dictionaries.

You for sure can + Roblox Datastores do that for you.

When I tried first time I got the error

[ProfileService]: DataStore API error Cannot store Dictionary in data store. Data stores can only accept valid UTF-8 characters."

Can you please show me your ProfileCacher module?

I’m using ProfileService

Yes I know about it but it seems like you are doing something wrong. Are you sure you don’t call any Set or UpdateAsync in your code?

Nope - Just editing the players Profile

Well that’s really weird I am working with massive dictionary data structures and never got this error. Can you please try it again without Encoding it with HttpService?

Yeah sure, just give me a few minutes.

Why not use HttpService:JSONEncode() to encode the data in the form of a string and decode it on load?

It is definitely worth a try.

Because datastores do that automatically for you.

Seems like you are trying to store Instance in datastore.

1 Like

@caviarbro Apparently not. This error should not have existed if that was true.

Now this is weird - I can now save the dictionary, but yesterday I couldn’t… Oh well, thanks ? Kinda confused on why I got the error yesterday.

1 Like

See my reply above you probably tried to save something that datastores don’t accept.

1 Like

So this error essentially occurs when we try to save an instance within a dictionary?

Yeah it seems like any non-acceptable datastore types (Instances/CFrames/Color etc.) will give you similiar error.

1 Like