when i tried to save the color but it not saves and gives error
i tried looking devforum but not worked
script:
local rs = game:GetService("ReplicatedStorage")
local data = require(game:GetService("ServerScriptService").DataStore2)
local test = require(script.test)
data.Combine("newonelol", "blood", "text")
local function convertStringToColor3(str)
return Color3.new(table.unpack(str:split(","))); -- the values in the string are seperated by a ",", remember?
end
game:GetService("Players").PlayerAdded:Connect(function(plr)
local valueStore = data("blood",plr)
local textStore = data("text",plr)
local plrgui = plr.PlayerGui
local settingsF = plrgui:WaitForChild("MainUI").SettingsFrame
local cloneExample = script.Example:Clone()
cloneExample.Parent = rs:WaitForChild("plrSettings")
local blood = cloneExample:WaitForChild("BloodEnabled")
local text = settingsF.BloodSet.Frame
local firstString = "85, 170, 127"
local SecS = "113, 1, 1"
local first = convertStringToColor3(firstString);
local sec = convertStringToColor3(SecS)
cloneExample.Name = plr.Name
valueStore:OnUpdate(function(new)
blood.Value = new
end)
textStore:OnUpdate(function(new)
text.BackgroundColor3 = new
end)
settingsF.BloodSetButton.MouseButton1Click:Connect(function()
if cloneExample:WaitForChild("BloodEnabled").Value == false then
valueStore:Set(true)
textStore:Set(first)
else
valueStore:Set(false)
textStore:Set(sec)
end
end)
end)
Either set the Color3 into a string and revert it back, or as a table with the R, G, B colors.
local color -- color3 value
-- string
local colorString = ""
for _, propertyName in pairs("R", "G", "B") do
colorString = colorString .. color[propertyName] .. (propertyName == "B" and "" or ", ")
end
-- now just seperate it with ", " and you get 3 values
-- table
local colorTable = {}
for _, propertyName in pairs("R", "G", "B") do
colorTable[propertyName] = color[propertyName]
end
local rs = game:GetService("ReplicatedStorage")
local data = require(game:GetService("ServerScriptService").DataStore2)
local test = require(script.test)
data.Combine("newonelol", "blood", "text")
local function convertStringToColor3(str)
return Color3.new(table.unpack(str:split(","))); -- the values in the string are seperated by a ",", remember?
end
game:GetService("Players").PlayerAdded:Connect(function(plr)
local valueStore = data("blood",plr)
local textStore = data("text",plr)
local plrgui = plr.PlayerGui
local settingsF = plrgui:WaitForChild("MainUI").SettingsFrame
local cloneExample = script.Example:Clone()
cloneExample.Parent = rs:WaitForChild("plrSettings")
local blood = cloneExample:WaitForChild("BloodEnabled")
local text = settingsF.BloodSet.Frame
local firstString = "85, 170, 127"
local SecS = "113, 1, 1"
local color = firstString
-- string
local colorString = ""
for _, propertyName in ipairs({"R", "G", "B"}) do
colorString = colorString .. color[propertyName] .. (propertyName == "B" and "" or ", ")
end
local colorTable = {}
for _, propertyName in ipairs({"R", "G", "B"}) do
colorTable[propertyName] = color[propertyName]
end
local color2 = SecS
-- string
local colorString = ""
for _, propertyName in ipairs({"R", "G", "B"}) do
colorString = colorString .. color2[propertyName] .. (propertyName == "B" and "" or ", ")
end
local colorTable = {}
for _, propertyName in ipairs({"R", "G", "B"}) do
colorTable[propertyName] = color2[propertyName]
end
cloneExample.Name = plr.Name
valueStore:OnUpdate(function(new)
blood.Value = new
end)
textStore:OnUpdate(function(new)
text.BackgroundColor3 = new
end)
settingsF.BloodSetButton.MouseButton1Click:Connect(function()
if cloneExample:WaitForChild("BloodEnabled").Value == false then
valueStore:Set(true)
textStore:Set(color)
else
valueStore:Set(false)
textStore:Set(color2)
end
end)
end)