Hello, when I run my game and leave it, I get this error:
104: Cannot store Dictionary in data store. Data stores can only accept valid UTF-8 characters.
note: I am not good with datastore
Code:
if game.ReplicatedStorage:FindFirstChild("Main"):FindFirstChild("IsRaining").Value == true then
game.ReplicatedStorage.Main.Rain:FireClient(player, "On")
end
local PlayerUserId = "Player_"..player.UserId
local leaderstats = Instance.new("Folder", player)
leaderstats.Name = "leaderstats"
local QuestValues = Instance.new("Folder", player)
QuestValues.Name = "QuestValues"
local ChakraNature = Instance.new("StringValue", leaderstats)
ChakraNature.Name = "ChakraNature"
local Clan = Instance.new("StringValue", leaderstats)
Clan.Name = "Clan"
local Rank = Instance.new("StringValue", leaderstats)
Rank.Name = "Rank"
local Coins = Instance.new("IntValue", leaderstats)
Coins.Name = "Coins"
Coins.Value = 0
local StrengthAdd = Instance.new("IntValue", player)
StrengthAdd.Name = "StrengthAdd"
StrengthAdd.Value = 0
local HealthAdd = Instance.new("IntValue", player)
HealthAdd.Name = "HealthAdd"
HealthAdd.Value = 0
local ToughnessAdd = Instance.new("IntValue", player)
ToughnessAdd.Name = "ToughnessAdd"
ToughnessAdd.Value = 0
local SpeedAdd = Instance.new("IntValue", player)
SpeedAdd.Name = "SpeedAdd"
SpeedAdd.Value = 0
local SkillPoints = Instance.new("IntValue", player)
SkillPoints.Name = "SkillPoints"
SkillPoints.Value = 0
local HokagecurrentQuestNumber = Instance.new("IntValue", player)
HokagecurrentQuestNumber.Name = "HokageCurrentQuestNumber"
HokagecurrentQuestNumber.Value = 1
local IrukaQuestNumber = Instance.new("IntValue", QuestValues)
IrukaQuestNumber.Name = "IrukaQuestNumber"
IrukaQuestNumber.Value = 0
local MaxChakra = Instance.new("IntValue", player)
MaxChakra.Name = "MaxChakra"
MaxChakra.Value = 20
local ChakraNumber = Instance.new("IntValue", player)
ChakraNumber.Name = "ChakraNumber"
ChakraNumber.Value = 10
local ChargingChakra = Instance.new("BoolValue", player)
ChargingChakra.Name = "ChargingChakra"
ChargingChakra.Value = false
local Main = Instance.new("Folder", player)
Main.Name = "Main"
local levels = Instance.new("IntValue", Main)
levels.Name = "levels"
levels.Value = 0
local xp = Instance.new("IntValue", Main)
xp.Name = "xp"
xp.Value = 0
local xpMultiplier = Instance.new("IntValue", Main)
xpMultiplier.Name = "xpMultiplier"
xp.Value = 0
--Load Data--
local Data
local success, errorMessage = pcall(function()
Data = leaderstatsStore:GetAsync(PlayerUserId)
end)
if success then
player:WaitForChild("leaderstats").ChakraNature.Value = Data.ChakraNature
player:WaitForChild("leaderstats").Clan.Value = Data.Clan
player:WaitForChild("leaderstats").Rank.Value = Data.Rank
player:WaitForChild("leaderstats").Coins.Value = Data.Coins
player:WaitForChild("SkillPoints").Value = Data.SkillPoints
player:WaitForChild("StrengthAdd").Value = Data.SrengthAdd
player:WaitForChild("HealthAdd").Value = Data.HealthAdd
player:WaitForChild("SpeedAdd").Value = Data.SpeedAdd
player:WaitForChild("QuestValues").IrukaQuestNumber.Value = Data.IrukaQuestNumber
player:WaitForChild("MaxChakra").Value = Data.MaxChakra
player:WaitForChild("ChakraNumber").Value = Data.MaxChakra
player:WaitForChild("Main").levels.Value = Data.levels
player:WaitForChild("Main").xp.Value = Data.xp
player:WaitForChild("Main"):WaitForChild("xpMultiplier").Value = Data.xpMuliplayer
print("Data loaded")
else
print("There was an error loading data")
warn(errorMessage)
end
end)
game.Players.PlayerRemoving:Connect(function(player)
local PlayerUserId = "Player_"..player.UserId
local Data = {
ChakraNature = player.leaderstats.ChakraNature.Value,
Clan = player.leaderstats.Clan.Value,
Rank = player.leaderstats.Rank.Value,
Coins = player.leaderstats.Coins.Value,
SkillPoints = player.SkillPoints.Value,
SrengthAdd = player.StrengthAdd.Value,
HealthAdd = player.HealthAdd.Value,
SpeedAdd = player.SpeedAdd.Value,
IrukaQuestNumber = player.QuestValues.IrukaQuestNumber.Value,
MaxChakra = player.MaxChakra.Value,
levels = player.Main.levels.Value,
xp = player.Main.xp.Value,
xpMuliplayer = player.Main.xpMultiplier
}
local success, errorMessage = pcall(function()
leaderstatsStore:SetAsync(PlayerUserId, Data)
end)
if success then
print("Data Successfully Saved")
else
print("There was an error saving data")
warn(errorMessage)
end
end)