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

The hair1color is a color3 and is not saving or loading, and I am unsure what to do?

Asked by 2 years ago
Edited 2 years ago

I have tried countless things, and none of them seem to work, I have been messing around with this script for a couple hours now trying to get the color3 to save and nothing has worked, the closest I got was changing it to a table, but even that didn't work

local function SerializeColor(colorValue)
    return {colorValue.R, colorValue.G, colorValue.B}
end

local function DeserializeColor(colorTable)
    return Color3.new(unpack(colorTable))
end

function save(plr)

    local s = {}

    for i, v in pairs(plr:WaitForChild("Data"):GetChildren())do


        s[i] = {[v.Name] = v.Value}

    end

    DSS:SetAsync(plr.UserId,http:JSONEncode(s)) 

end

game.Players.PlayerAdded:Connect(function(Player)

    local folder = Instance.new("Folder", Player)
    folder.Name = "Data"

    local firsthair = Instance.new("StringValue", folder)
    firsthair.Name = "FirstHair"
    firsthair.Value = "Hair1"

local hair1Color = Instance.new("Color3Value", folder)
    hair1Color.Name = "Hair1Color"
    SerializeColor(hair1Color.Value)
    hair1Color.Value = Color3.new(1, 0.321569, 0.560784)

    local success, errorm = pcall(function()

        local loaded = http:JSONDecode(DSS:GetAsync(Player.UserId))

        if loaded then

            print(loaded)

            for i, v in pairs(loaded)do
                for i2, v2 in pairs(v)do
                    if folder:FindFirstChild(i2) then
                        folder:FindFirstChild(i2).Value = v2
                    end
                end
            end

        end

    end)

        if workspace.Dummy.Head:FindFirstChild("face") then
            workspace.Dummy.Head:FindFirstChild("face"):Destroy()
            workspace.Dummy.Head.face.Texture = face.Value
        end

        local x = script.Parent.Hair1[firsthair.Value]:Clone()
        x.Name = "FirstHair"
    x.Handle.Color = Color3.new(hair1Color.Value.R,hair1Color.Value.G,hair1Color.Value.B)
        x.Parent = workspace.Dummy

Answer this question