What do you want to achieve?
I want to be able to store a Color3 value in a dataStore but not in the leaderstats.
What is the issue?
Im getting this error " Unable to assign property Value. Color3 expected, got number"
Here is the value
What solutions have you tried so far?
Ive tried looking on youtube, devforum and asking on the discord server
DataStore script
local DS = game:GetService("DataStoreService"):GetDataStore("Save")
local gen = game:GetService("ReplicatedStorage").Gen
game.Players.PlayerAdded:Connect(function(plr)
local didjoin = false
local firsttime = false
local success, joined = pcall(function()
return DS:GetAsync(plr.UserId)
end)
if success then
if joined == 1 then
didJoin = true
print("Not First Time")
else
DS:SetAsync(plr.UserId, 1)
firstTime = true
gen:FireClient(plr)
print("First Time")
end
end
local plrkey = "id"..plr.userId
local savevalue = plr.leaderstats.Letters
local shirtValue = plr.miscValues.shirtColor
local isMaleValue = plr.miscValues.isMale
local GetSaved = DS:GetAsync(plrkey)
if GetSaved then
savevalue.Value = GetSaved[1]
shirtValue.Value = GetSaved[1]
isMaleValue.Value = GetSaved[1]
else
local NumbersForSaving = {savevalue.Value}
local NumbersForSaving2 = {shirtValue.Value}
local NumbersForSaving3 = {isMaleValue.Value}
DS:GetAsync(plrkey, NumbersForSaving)
DS:GetAsync(plrkey, NumbersForSaving2)
DS:GetAsync(plrkey, NumbersForSaving3)
end
end)
game.Players.PlayerRemoving:Connect(function(plr)
DS:SetAsync("id"..plr.userId, {plr.leaderstats.Letters.Value})
DS:SetAsync("id"..plr.userId, {plr.miscValues.shirtColor.Value})
DS:SetAsync("id"..plr.userId, {plr.miscValues.isisMale.Value})
end)
leaderstats script
local DATAStoreService = game:GetService("DataStoreService")
local myDataStorage = DATAStoreService:GetDataStore("myDataScore")
game.Players.PlayerAdded:Connect(function(player)
local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
leaderstats.Parent = player
local words = Instance.new("IntValue")
words.Name = "Letters"
words.Parent = leaderstats
local leaderstats = player.leaderstats
local miscValues = Instance.new("Folder")
miscValues.Name = "miscValues"
miscValues.Parent = player
local shirtColor = Instance.new("Color3Value")
shirtColor.Name = "shirtColor"
shirtColor.Parent = miscValues
local isMale = Instance.new("BoolValue")
isMale.Name = "isMale"
isMale.Parent = miscValues
local miscValues = player.miscValues
end)
Theres also a error called
104: Cannot store Array in data store. Data stores can only accept valid UTF-8 characters.
but I think it will dissapear once I store the Color3 correctly
local DS = game:GetService("DataStoreService"):GetDataStore("Save")
local gen = game:GetService("ReplicatedStorage").Gen
game.Players.PlayerAdded:Connect(function(plr)
local didjoin = false
local firsttime = false
local success, joined = pcall(function()
return DS:GetAsync(plr.UserId)
end)
if success then
if joined == 1 then
didJoin = true
print("Not First Time")
else
DS:SetAsync(plr.UserId, 1)
firstTime = true
gen:FireClient(plr)
print("First Time")
end
end
local plrkey = "id"..plr.userId
local savevalue = plr.leaderstats.Letters
local shirtValue = plr.miscValues.shirtColor
local isMaleValue = plr.miscValues.isMale
local GetSaved = DS:GetAsync(plrkey)
if GetSaved then
local shirtColorValue = GetSaved[1]["ShirtColors"]
savevalue.Value = GetSaved[1]
shirtValue.Value = Color3.fromRGB(shirtColorValue["R"], shirtColorValue["G"], shirtColorValue["B"])
isMaleValue.Value = GetSaved[1]
else
local NumbersForSaving = {savevalue.Value}
local NumbersForSaving2 = {shirtValue.Value}
local NumbersForSaving3 = {isMaleValue.Value}
DS:GetAsync(plrkey, NumbersForSaving)
DS:GetAsync(plrkey, NumbersForSaving2)
DS:GetAsync(plrkey, NumbersForSaving3)
end
end)
game.Players.PlayerRemoving:Connect(function(plr)
local plrShirtColor = plr.miscValues.shirtColor
local shirtColors = {
["ShirtColors"] = {
["R"] = plrShirtColor.Value.R;
["G"] = plrShirtColor.Value.G;
["B"] = plrShirtColor.Value.B;
}
}
DS:SetAsync("id"..plr.userId, {plr.leaderstats.Letters.Value})
DS:SetAsync("id"..plr.userId, {shirtColors})
DS:SetAsync("id"..plr.userId, {plr.miscValues.isisMale.Value})
end)
I’m not 100% sure if that’ll work for not as I haven’t tested it out, let me know
" ServerScriptService.SaveData:35: attempt to index boolean with ‘ShirtColors’ - Server - SaveData:35"
I think u meant [shirtValue.Value] but that didnt work neither