local datastore = dss:GetDataStore("Data")
game.Players.PlayerAdded:Connect(function(player)
local folder = Instance.new("Folder",player)
folder.Name = "Folder"
local Color = Instance.new("Color3Value",folder)
Color.Name = "Color3"
local saved
local success, result = pcall(function ()
return datastore:GetAsync(player.UserId)
end
if success and result then -- I do not advise this pattern
Color.Value = Color3.new(table.unpack(string.split(saved.Color, ", ")))
end
end)
game.Players.PlayerRemoving:Connect(function(player)
local saved = {
["Color"] = tostring(player.Folder.Color3.Value)
}
local done, errors = pcall(function()
datastore:SetAsync(player.UserId,saved)
end)
if done then
print("Saved " ..player.Name.. ", 's Data!")
else
print("Error Saving!")
warn(errors)
end
end)
Well your not saving anything called Color3
game.Players.PlayerAdded:Connect(function(player)
local folder = Instance.new("Folder",player)
folder.Name = "Folder"
local Color = Instance.new("Color3Value",folder)
Color.Name = "Color3"
local saved
local done, errors = pcall(function()
saved = datastore:GetAsync(player.UserId)
end)
if done then
Color.Value = saved.Color --Instead of Color3 we are going to do saved.Color or saved["Color"]. Whatever you prefer.
end
end)
How are you sure it’s not saving? Have you done your own debugging or checked the console for any errors? What you’re doing isn’t valid so there’s definitely an unchecked error in your console.
Your save function turns the value of a Color3Value into a string and saves it, that’s fine. However, when you go retrieve this value, not only are you trying to index a nonexistent value in your dictionary (you’re indexing Color3 instead of Color) but you’re trying to apply a string to something that only accepts a Color3Value which is invalid.
local success, result = pcall(function ()
return datastore:GetAsync(player.UserId)
end
if success and result then -- I do not advise this pattern
Color.Value = Color3.new(table.unpack(string.split(saved.Color, ", ")))
end