Hi! So I made a custom character creation system, and when they finished it, they get teleported back to the lobby. I wanna make it so when they hit ‘x’ button, the custom character they made will load back without losing any data. The problem is : I get this error :
09:06:32.823 104: Cannot store Dictionary in data store. Data stores can only accept valid UTF-8 characters. - Server - DataStore1:99
I checked out devhub + devforum, but I couldn’t really find anything.
Here is my script so far
local DataStoreService = game:GetService("DataStoreService")
local DataStoreService = game:GetService("DataStoreService")
local slot1 = DataStoreService:GetDataStore("Slot1")
local HTTP = game:GetService("HttpService")
game.Players.PlayerAdded:Connect(function(player)
local folder = Instance.new("Folder",player)
folder.Name = "Slot1"
local c = game.StarterPlayer.StarterCharacter:Clone()
c.Parent = folder
local playerUserId = "Player_"..player.UserId
local data
local succes, errormessage = pcall(function()
data = slot1:GetAsync(playerUserId, slot1)
end)
if succes then
local data = {
mesh = player.Slot1.StarterCharacter.Hair.Mesh;
ofs = player.Slot1.StarterCharacter.Hair.Mesh.Offset;
s = player.Slot1.StarterCharacter.Hair.Mesh.Scale;
hc = player.Slot1.StarterCharacter.Hair.Color;
sc = player.Slot1.StarterCharacter["Body Colors"].HeadColor;
shirt = player.Slot1.StarterCharacter.Clothing.ShirtTemplate;
pants = player.Slot1.StarterCharacter.Pants.PantsTemplate;
class = player.Slot1.StarterCharacter.Class.Value;
code = player.Slot1.StarterCharacter.CodeName.Value;
}
end
end)
game.StarterGui.InsertedObjects.Slot1.MouseButton1Up:Connect(function(player)
local playerUserId = "Player_"..player.UserId
local succes, errormessage = pcall(function()
local data = {
mesh = player.Slot1.StarterCharacter.Hair.Mesh;
ofs = player.Slot1.StarterCharacter.Hair.Mesh.Offset;
s = player.Slot1.StarterCharacter.Hair.Mesh.Scale;
hc = player.Slot1.StarterCharacter.Hair.Color;
sc = player.Slot1.StarterCharacter["Body Colors"].HeadColor;
shirt = player.Slot1.StarterCharacter.Clothing.ShirtTemplate;
pants = player.Slot1.StarterCharacter.Pants.PantsTemplate;
class = player.Slot1.StarterCharacter.Class.Value;
code = player.Slot1.StarterCharacter.CodeName.Value;
}
slot1:SetAsync(playerUserId, data)
end)
if succes then
local data = {
mesh = player.Slot1.StarterCharacter.Hair.Mesh;
ofs = player.Slot1.StarterCharacter.Hair.Mesh.Offset;
s = player.Slot1.StarterCharacter.Hair.Mesh.Scale;
hc = player.Slot1.StarterCharacter.Hair.Color;
sc = player.Slot1.StarterCharacter["Body Colors"].HeadColor;
shirt = player.Slot1.StarterCharacter.Clothing.ShirtTemplate;
pants = player.Slot1.StarterCharacter.Pants.PantsTemplate;
class = player.Slot1.StarterCharacter.Class.Value;
code = player.Slot1.StarterCharacter.CodeName.Value;
}
game.StarterGui.InsertedObjects.Slot1.Class.Text = data.class
end
end)
game.Players.PlayerRemoving:Connect(function(player)
local playerUserId = "Player_"..player.UserId
local data = {
mesh = player.Slot1.StarterCharacter.Hair.Mesh;
ofs = player.Slot1.StarterCharacter.Hair.Mesh.Offset;
s = player.Slot1.StarterCharacter.Hair.Mesh.Scale;
hc = player.Slot1.StarterCharacter.Hair.Color;
sc = player.Slot1.StarterCharacter["Body Colors"].HeadColor;
shirt = player.Slot1.StarterCharacter.Clothing.ShirtTemplate;
pants = player.Slot1.StarterCharacter.Pants.PantsTemplate;
class = player.Slot1.StarterCharacter.Class.Value;
code = player.Slot1.StarterCharacter.CodeName.Value;
}
local playerUserId = "Player_"..player.UserId
slot1:SetAsync(playerUserId, data)
end)
I’m not a master of datastores, but can someone help me? I would really need it to my game.