Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Color3.fromRGB() becoming black?

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

✓ Accepted answer

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 comment

1

Cool, thanks for telling me!

This discussion is preserved as it was. New answers, comments, and votes are closed.