here is what the error says Cannot store int in data store. Data stores can only accept valid UTF-8 characters
local module = {}
local DataStore = game:GetService("DataStoreService"):GetDataStore("***********")
game.Players.PlayerAdded:Connect(function(plr)
local Folder = Instance.new("Folder") Folder.Name = "Person" Folder.Parent = plr
local Color = Instance.new("BrickColorValue") Color.Name = "Color" Color.Value = BrickColor.new("Pastel brown") Color.Parent = Folder
local SavedColor = DataStore:GetAsync(plr.userId .. "-Color") if SavedColor ~= nil then Color.Value = SavedColor end
end)
game.Players.PlayerRemoving:connect(function(plr) local id = plr.userId local ColValue = plr.Person.Color.Value DataStore:SetAsync(id.."-Color", ColValue)
end)
return module
Ok, You can't save any Roblox instances in datastores. Correct me if wrong, Datastores will only accept tables, string, numbers, booleans etc... However, that does not mean you can't do what you're trying to do. You can actually just save these numbers in a table example would be
local newColor = ColorV.Value local colorT = {newColor.r,newColor.g,newColor.b}
Once doing this, you can then save the table colorT under the given data key and retrieve it by using the table indexes upon loading the data.
Oh, Use pcalls in your data retrieving because sometimes data stores can fail and you don't want your script to stop working because of a failed data retrieve.
The wiki for datastores has pcalls implemented with datastore. Roblox API: Datastores
If this helps an upvote and solved would be appreciated. :)