Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why isn't my Color3 saving in DataStore?

Asked by 5 years ago

I'm trying to save my Color3 in DataStore but what I've tried hasn't worked and the script is kind of broken atm so it doesn't work :/ Please help me fix it.

local DataStoreService = game:GetService("DataStoreService")

local RGBValue = DataStoreService:GetDataStore("CACDataStoreKiRGB")



                game.ReplicatedStorage.SendColor1.OnServerEvent:Connect(function(player, Color3Value)

                player.CACData.KiRGB.Value = Color3Value

            end)

game:GetService("Players").PlayerAdded:Connect(function(player)

        local CACData = player.CACData

            player:WaitForChild("CACData")

            local KiRGB = player.CACData.KiRGB

            local function loadColor3FromDataStore(KiRGB)

                    return Color3.new(KiRGB.r, KiRGB.g, KiRGB.b)

            end

                KiRGB.Value = RGBValue:GetAsync(player.UserId, loadColor3FromDataStore())

function getSaveableColor3(KiRGB)

return {r = player.CACData.Red.Value, g = player.CACData.Green.Value, b = player.CACData.Blue.Value}

end

        game.ReplicatedStorage.SaveData.OnServerEvent:Connect(function(player)

        KiRGB.Value = RGBValue:SetAsync(player.UserId, Color3.fromRGB(getSaveableColor3(KiRGB)))

    end)

end)

Answer this question