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

Color3.fromRGB() becoming black?

Asked by 3 years ago
Edited 3 years ago

I'm attempting to create a Name script with a /color {arg} feature. But when using a dictionary of colors, it becomes black.

SAMPLE:

local Colors = {
    ["red"] = "255, 0, 0",
    ["orange"] = "255, 170, 0",
    ["yellow"] = "255, 255, 0",
    ["green"] = "0, 255, 0",
    ["blue"] = "0, 0, 255",
    ["lavender"] = "170, 0, 255",
    ["white"] = "255, 255, 255",
    ["black"] = "0, 0, 0",
    ["gold"] = "255,223,0"
}

local function color(player, arg)
    for i, v in pairs(Colors) do
        if arg == i then
            print(i, v)
            player.Character.Head.RPName.Text.TextColor3 = Color3.fromRGB(tonumber(v))
        end
    end
end

1 answer

Log in to vote
1
Answered by
imKirda 4491 Moderation Voter Community Moderator
3 years ago

Instead of creating strings like "255, 50, 0" create RGB values like this:

local Colors = {
    ["red"] = Color3.fromRGB(255, 0, 0),
    ["orange"] = Color3.fromRGB(255, 170, 0),
    ["yellow"] = Color3.fromRGB(255, 255, 0),
}

player.Character.Head.RPName.Text.TextColor3 = v
1
Cool, thanks for telling me! loowa_yawn 383 — 3y
Ad

Answer this question