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 6 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.

01local DataStoreService = game:GetService("DataStoreService")
02 
03local RGBValue = DataStoreService:GetDataStore("CACDataStoreKiRGB")
04 
05   
06 
07                game.ReplicatedStorage.SendColor1.OnServerEvent:Connect(function(player, Color3Value)
08                 
09                player.CACData.KiRGB.Value = Color3Value
10 
11            end)
12     
13game:GetService("Players").PlayerAdded:Connect(function(player)
14 
15        local CACData = player.CACData
16 
17            player:WaitForChild("CACData")
18 
19            local KiRGB = player.CACData.KiRGB
20 
21            local function loadColor3FromDataStore(KiRGB)
22 
23                    return Color3.new(KiRGB.r, KiRGB.g, KiRGB.b)
24 
25            end
26 
27                KiRGB.Value = RGBValue:GetAsync(player.UserId, loadColor3FromDataStore())
28 
29function getSaveableColor3(KiRGB)
30 
31return {r = player.CACData.Red.Value, g = player.CACData.Green.Value, b = player.CACData.Blue.Value}
32 
33end
34 
35        game.ReplicatedStorage.SaveData.OnServerEvent:Connect(function(player)
36     
37        KiRGB.Value = RGBValue:SetAsync(player.UserId, Color3.fromRGB(getSaveableColor3(KiRGB)))
38 
39    end)
40 
41end)

Answer this question