I can't save a item for UNKNOWN REASON?

  1. I wanna save material to datastore as name, position


I can’t save red circled one while i can save up ohter any items

  1. Extra output:
    DataStoreService: CantStoreValue: Cannot store in data store. Data stores can only accept valid UTF-8 characters. API: UpdateAsync,
for _, item in ipairs(ItemsFolder:GetChildren()) do
		local bufferXYZ = Vector3.new(DataSettings.ItemSaveDistanceByPlot, DataSettings.ItemSaveDistanceByPlot, DataSettings.ItemSaveDistanceByPlot)

		local minBound = CurrentPlot.MainFloor.Position - (CurrentPlot.MainFloor.Size / 2) - bufferXYZ
		local maxBound = CurrentPlot.MainFloor.Position + (CurrentPlot.MainFloor.Size / 2) + bufferXYZ

		local ValidPosition =  (item.PrimaryPart.Position.X >= minBound.X and item.PrimaryPart.Position.X <= maxBound.X) and
			(item.PrimaryPart.Position.Y >= minBound.Y and item.PrimaryPart.Position.Y <= maxBound.Y) and
			(item.PrimaryPart.Position.Z >= minBound.Z and item.PrimaryPart.Position.Z <= maxBound.Z)

		if ValidPosition then
			local baseCF = CurrentPlot.BuildFloor.MainPlot.Main.CFrame
			local cf = item:GetPivot()
			local relativeCF = baseCF:ToObjectSpace(cf)

			local x, y, z = relativeCF:ToOrientation()

			local cfTable = {
				Position = {relativeCF.Position.X, relativeCF.Position.Y, relativeCF.Position.Z},
				Orientation = {math.deg(x), math.deg(y), math.deg(z)}
			}
			
			table.insert(SavingInstances.Items, {ItemName = item.Name, ItemCFrame = cfTable})
		end
	end
2 Likes

Now I wouldn’t happen to know why an underscore is not a “valid UTF-8 character” if this is an issue with the name of the model if that is the actual issue here because UTF-8 is just Unicode Transformation Format 8-bit, meaning it’s likely an issue with some named object but an underscore is supported by the official technical standard, so I would have no idea why it’d be restricted here assuming the underscore in the name is the thing to cause this issue. I don’t know otherwise.

Hope this intel helps though. :folded_hands:

1 Like

Print the values of item.name and cfTable the line before the table.insert and look for anything odd. Duplicate the problem model and manually name it something simple and check that. Find something that does work, duplicate it and copy paste the problem model name into and test. I’m going to guess there is something weird in the cframe, but you can do some simple testing.

I would try printing your SavingInstances table. Better yet, try encoding it via HTTPService:JSONEncode, as all stored data is encoded to JSON when saved to a GlobalDataStore. It will throw an error if it fails to encode (edit: it doesn’t, IIRC it used to but I assume they changed it?).

All of the characters within TreeLog_RawMaterial are valid UTF-8 characters. Though, I wouldn’t write off the chance that there’s some evil zero-width character in your model’s name that is causing it to not serialize correctly.

4 Likes

Idk ohter items saving good i only have problem on that

Did you try this? Just printing the SavingInstances table won’t really yield anything important if you don’t know its serialized value

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.