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

color is off for my gui script?

Asked by 10 years ago
local last = nil
local function turnOrange(new)
    if last ~= nil then
        if new.Name ~= last.Name then
            new.TextColor3 = Color3.new(227, 125, 0)
            last.TextColor3 = Color3.new(0, 31, 168)
        end
    else new.TextColor3 = Color3.new(0, 31, 168)
    end
    last = new
end 

for i, v in pairs(script.Parent.Parent:GetChildren()) do
    if v:IsA("TextButton") and v.Name ~= "Select" then
        v.MouseButton1Click:connect(function()
            turnOrange(v) 
        end)
    end
end

soo the script, is completely fine but the color change is off, i want it to chnage orange but it changes yellow, i checked the numbers for orange and i have it correct but it doesnt work also the normal color of the text is dark blue but after i click on it and click another button it turns like teal blue, are there any reasons why this is happening

1 answer

Log in to vote
0
Answered by
Azarth 3141 Moderation Voter Community Moderator
10 years ago

You basically just need to divide each number by 255 or make a function that does it for you.

local last = nil

local function convert_rgb(color)
    local rgb = {}
    -- Table to return vals
    for i in string.gmatch(tostring(color), "%d+") do 
        -- Find the pattern, in this case it's the numbers before each comma. 
        rgb[#rgb+1] = i/255
        -- Store the value divided by 255
    end
    return Color3.new(unpack(rgb))
    -- return the divided rgb vals.
end

local function turnOrange(new)
    if last ~= nil then
        if new.Name ~= last.Name then
            new.TextColor3 = convert_rgb(Color3.new(227, 125, 0))
            last.TextColor3 = convert_rgb(Color3.new(0, 31, 168))
        end
    else 
        new.TextColor3 = convert_rgb(Color3.new(0, 31, 168))
    end
    last = new
end 

for i, v in pairs(script.Parent.Parent:GetChildren()) do
    if v:IsA("TextButton") and v.Name ~= "Select" then
        v.MouseButton1Click:connect(function()
            turnOrange(v) 
        end)
    end
end

0
do u have links that would help me learn what u just did, im still kinda new at this scripting thing namelessassasin 30 — 10y
0
Just search 'roblox wiki ' what you're looking for here ' ' Azarth 3141 — 10y
Ad

Answer this question