Hi, i’m making a game where there is a save and load function, and colors are stored in Color3Values. But some colors don’t get saved because they get changed when inserted in game, which makes my save and load functions not work.
Here is the functions:
LOAD
local function getColor(colorCode)
local colors = workspace.ColorValues
if colorCode == 0 then
return colors.Brown.Value --Brown
elseif colorCode == 1 then
return colors.GrassGreen.Value --Grass Green
elseif colorCode == 2 then
return colors.EarthGreen.Value --Earth Green
elseif colorCode == 3 then
return colors.StoneGray.Value --Stone Gray
elseif colorCode == 4 then
return colors.BrightRed.Value --Bright Red
elseif colorCode == 5 then
return colors.BrightOrange.Value --Bright Orange
elseif colorCode == 6 then
return colors.BrightYellow.Value --Bright Yellow
elseif colorCode == 7 then
return colors.BrightGreen.Value --Bright Green
elseif colorCode == 8 then
return colors.BrightBlue.Value --Bright Blue
elseif colorCode == 9 then
return colors.BrightViolet.Value --Bright Violet
elseif colorCode == 10 then
return colors.White.Value --White
elseif colorCode == 11 then
return colors.Black.Value --Black
elseif colorCode == 12 then
return colors.Pink.Value --Pink
elseif colorCode == 13 then
return colors.CottonPink.Value --CottonPink
elseif colorCode == 14 then
return colors.CottonBlue.Value --CottonBlue
elseif colorCode == 15 then
return colors.LightBrown.Value
elseif colorCode == 16 then
return colors.Turquoise.Value
elseif colorCode == 17 then
return colors.PumpkinOrange.Value
elseif colorCode == 18 then
return colors.Red.Value
elseif colorCode == 19 then
return colors.Green.Value
elseif colorCode == 20 then
return colors.Blue.Value
elseif colorCode == 21 then
return colors.Bread.Value
elseif colorCode == 22 then
return colors.BluishGreen.Value
elseif colorCode == 23 then
return colors.Yellow.Value
else
return colors.StoneGray.Value
end
end
SAVE
local function convertColor(colorCode)
local colors = workspace.ColorValues
if colorCode == colors.Brown.Value then
return 0 --Brown
elseif colorCode == colors.GrassGreen.Value then
return 1 --Grass Green
elseif colorCode == colors.EarthGreen.Value then
return 2 --Earth Green
elseif colorCode == colors.StoneGray.Value then
return 3 --Stone Gray
elseif colorCode == colors.BrightRed.Value then
return 4 --Bright Red
elseif colorCode == colors.BrightOrange.Value then
return 5 --Bright Orange
elseif colorCode == colors.BrightYellow.Value then
return 6 --Bright Yellow
elseif colorCode == colors.BrightGreen.Value then
return 7 --Bright Green
elseif colorCode == colors.BrightBlue.Value then
return 8 --Bright Blue
elseif colorCode == colors.BrightViolet.Value then
return 9 --Bright Violet
elseif colorCode == colors.White.Value then
return 10 --White
elseif colorCode == colors.Black.Value then
return 11 --Black
elseif colorCode == colors.Pink.Value then
return 12 --Pink
elseif colorCode == colors.CottonPink.Value then
return 13 --CottonPink
elseif colorCode == colors.CottonBlue.Value then
return 14 --CottonBlue
elseif colorCode == colors.LightBrown.Value then
return 15 --LightBrown
elseif colorCode == colors.Turquoise.Value then
return 16
elseif colorCode == colors.PumpkinOrange.Value then
return 17
elseif colorCode == colors.Red.Value then
return 18
elseif colorCode == colors.Green.Value then
return 19
elseif colorCode == colors.Blue.Value then
return 20
elseif colorCode == colors.Bread.Value then
return 21
elseif colorCode == colors.BluishGreen.Value then
return 22
elseif colorCode == colors.Yellow.Value then
return 23
else
return 3
end
end
SELECTING COLOR
local scrollingFrame = script.Parent.ScrollingFrame
local player = script.Parent.Parent.Parent.Parent.Parent
for _, v in pairs(scrollingFrame:GetChildren()) do
v:SetAttribute("ValueActive", false)
local color = workspace.ColorValues:FindFirstChild(v.Name).Value
v.UIText:Destroy()
v.BackgroundColor3 = color
v.MouseButton1Click:Connect(function()
if v:GetAttribute("ValueActive") == false then
print("Choosing Color: "..v.Text)
v:SetAttribute("ValueActive", true)
workspace.Settings[player.Name.."_Settings"].Color.Value = color
v:SetAttribute("ColorText", v.Text)
v.Text = "✅"
task.wait(1)
v.Text = v:GetAttribute("ColorText")
v:SetAttribute("ValueActive", false)
end
end)
end
SETTING PART COLOR
shape.Color = workspace.Settings[player.Name.."_Settings"].Color.Value