Hi i’d like to know how to convert a BrickColor value to a Color3 (RGB) value ?
I searched on the devforum but I found nothing
script:
local ColorGUI = game.Players.LocalPlayer.PlayerGui.ColorSeqGUI
local Chiffre = ColorGUI.CodeValue
local Colors = {"Really red","New Yeller","Lime green","Cyan"}
local inputs = ColorGUI.Frame.Frame.Code
game.ReplicatedStorage.EnableGUI.OnClientEvent:Connect(function()
ColorGUI.Enabled = true
ColorGUI.Frame:TweenPosition(UDim2.new(0,0,0,0),"Out","Back",1,false)
end)
ColorGUI.Frame.X.MouseButton1Click:Connect(function()
ColorGUI.Enabled = false
ColorGUI.Frame.Position = UDim2.new(-1,0,0,0)
end)
for i ,key in pairs(inputs:GetChildren()) do
if string.find(key.Name, "Key") then
key.MouseButton1Click:Connect(function()
script.Parent.TypinDacode:Play()
key.BackgroundColor3 = -- ???? ( I need to convert Colors table values to RGB Values )
end)
elseif key.Name == "Enter" then
key.MouseButton1Click:Connect(function()
script.Parent.TypinDacode:Play()
game.ReplicatedStorage.EnableGUI:FireServer(Chiffre.Value)
end)
end
end
this script is for a colorsequence code door
4 Likes
You can simply do
BrickColor.Color
Where BrickColor
is the BrickColor to get the Color3 from
Judging from your thing, You have a table with just the names. I think you can do
local Colors = {BrickColor.new("Really red").Color,
BrickColor.new("New Yeller").Color,
BrickColor.new("Lime green").Color,
BrickColor.new("Cyan").Color
}
For the table and then in your BackgroundColir3, just get the color you want from the Index, so you wanted the 2nd color, just do Colors[2]
as an example
28 Likes
thanks for the help! imma try this and let you know if this works
1 Like
Thanks this works! Now i’m stuck again for something else :
I want to, when the player clicks on the textbutton, it changes color from 1 ( example: Red to yellow, yellow to green, green to blue, blue to red…)
how could I do that ?
Simple! You can have a variable that stores the current index
local index = 1
Then in your BackgroundColor3 line, use that index variable to change the color depending on the index in the table
BackgroundColor3 = Colors[index]
Then increment by 1 if it’s not 4 or 1 if it is 4
index = index == 4 and 1 or index + 1
This is basically the same as
if index == 4 then
index = 1
else
index += 1
end
Or if you want it to scale when you add more colors, just do
index = index == #Colors and 1 or index + 1
2 Likes
ok thanks a lot ! Have a great day or night!
2 Likes