Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

I am trying to make a Datastore to save Maps in my game, but it gives me this error. Any help?

I am currently fixing one of my games' Map Datastore, but when I leave the game it keeps giving me this error in the output:

104: Cannot store Instance in data store. Data stores can only accept valid UTF-8 characters.  -  Server

I have absolutely no idea what this means and there are no youtube videos or developer articles about this.

This is the script for my Map Datastore. The Datastore Script itself is located in the ServerScriptService.

local datastoreService = game:GetService("DataStoreService")
local rs = game:GetService("ReplicatedStorage")

local map2Datastore = datastoreService:GetDataStore("Map2Datastore_A")
local map3DataStore = datastoreService:GetDataStore("Map3Datastore_A")
local map4Datastore = datastoreService:GetDataStore("Map4Datastore_A")
local map5DataStore = datastoreService:GetDataStore("Map5Datastore_A")

game.Players.PlayerAdded:Connect(function(plr)
	local mapsFolder = Instance.new("Folder")
	mapsFolder.Name = "MapsFolder"
	mapsFolder.Parent = plr
	
	local map2Value = Instance.new("IntValue")
	map2Value.Name = "Map2Value"
	map2Value.Parent = mapsFolder
	
	local map3Value = Instance.new("IntValue")
	map3Value.Name = "Map3Value"
	map3Value.Parent = mapsFolder
	
	local map4Value = Instance.new("IntValue")
	map4Value.Name = "Map4Value"
	map4Value.Parent = mapsFolder
	
	local map5Value = Instance.new("IntValue")
	map5Value.Name = "Map5Value"
	map5Value.Parent = mapsFolder
	
	
	local MapData2
	local MapData3
	local MapData4
	local MapData5
	
	local success, errormessage = pcall(function()
		MapData2 = map2Datastore:GetAsync(plr.UserId.."-map2")
		MapData3 = map3DataStore:GetAsync(plr.UserId.."-map3")
		MapData4 = map4Datastore:GetAsync(plr.UserId.."-map4")
		MapData5 = map5DataStore:GetAsync(plr.UserId.."-map5")
	end)
	
	if success then
		map2Value.Value = MapData2
		map3Value.Value = MapData3
		map4Value.Value = MapData4
		map5Value.Value = MapData5
	else
		print("There was an error MapDatastore.")
		warn(errormessage)
	end
end)

game.Players.PlayerRemoving:Connect(function(player)
	local success, errormessage = pcall(function()
		map2Datastore:SetAsync(player.UserId.."-map2", player.MapsFolder.Map2Value)
		map3DataStore:SetAsync(player.UserId.."-map3", player.MapsFolder.Map3Value)
		map4Datastore:SetAsync(player.UserId.."-map4", player.MapsFolder.Map4Value)
		map5DataStore:SetAsync(player.UserId.."-map5", player.MapsFolder.Map5Value)
	end)
	
	if success then
		print("Successfully saved Map Data!")
	else
		print("There was an error while saving Map Data!")
		warn(errormessage)
	end
end)

Any help on this?

4 comments

0

what the output says??

0

alsoo, in the script, which is the line underlined in red?

0

i said at the top what the output says

0

104: Cannot store Instance in data store. Data stores can only accept valid UTF-8 characters. - Server

1 answer

This discussion is preserved as it was. New answers, comments, and votes are closed.