Skin color turn blue on math.random

So for some reason the random.random skin color turns blue. It picks a random color from a talbe and then turns it into a color, but it ends up blue. I think they might get scrambled.

local skinColors = {
	"255, 245, 223",
	"255, 221,196",
	"255, 217,174",
	"255, 203, 147",
	"246, 226, 172",
	"255, 216, 185",
	"238, 194, 168",
	"220, 183, 139",
	"243, 183, 141",
	"231, 173, 134",
	"228, 171, 132",
	"205, 154, 119",
	"202, 149, 117",
	"214, 139, 98",
	"204, 138, 111",
	"196, 139, 105",
	"198, 127, 90",
	"180, 113, 81",
	"164, 103, 74",
	"147, 92, 65",
	"134, 85, 60",
	"165, 115, 88",
	"152, 105, 81",
	"142, 100, 77",
	"134, 85, 60",
	"137, 58, 46",
	"136, 65, 67",
	"145, 52, 0",
	"109, 68, 49",
	"88, 53, 39",
	"76, 46, 33",
	"65, 39, 28",
}

local randomSkinColor = skinColors[math.random(1,#skinColors)]

local color = string.split(randomSkinColor, ", ")
				
bodyPart.Color = Color3.new(table.unpack(color))

Use fromRGB since your using values above 1

Color3.fromRGB()

like @x6nnx said, use fromRGB()

Nothing gets mixed up, if you print color after the variable, you’ll have a properly selected color

Color3.new will always give different shades of blue for some reason

Color3.new() requires values between 0 and 1

So if he wants to use Color3.new()

He can do this

local skinColors = {
	"255, 245, 223",
	"255, 221,196",
	"255, 217,174",
	"255, 203, 147",
	"246, 226, 172",
	"255, 216, 185",
	"238, 194, 168",
	"220, 183, 139",
	"243, 183, 141",
	"231, 173, 134",
	"228, 171, 132",
	"205, 154, 119",
	"202, 149, 117",
	"214, 139, 98",
	"204, 138, 111",
	"196, 139, 105",
	"198, 127, 90",
	"180, 113, 81",
	"164, 103, 74",
	"147, 92, 65",
	"134, 85, 60",
	"165, 115, 88",
	"152, 105, 81",
	"142, 100, 77",
	"134, 85, 60",
	"137, 58, 46",
	"136, 65, 67",
	"145, 52, 0",
	"109, 68, 49",
	"88, 53, 39",
	"76, 46, 33",
	"65, 39, 28",
}

local randomSkinColor = skinColors[math.random(1,#skinColors)]

local color = string.split(randomSkinColor, ", ")

for i, v in pairs(color) do
    color[i] = v/255
end

bodyPart.Color = Color3.new(table.unpack(color))
1 Like

Also why not just store the Color3 value in the table?

local skinColors = {
	Color3.fromRGB(255, 245, 223);
	Color3.fromRGB(255, 221,196);
	Color3.fromRGB(255, 217,174);
	Color3.fromRGB(255, 203, 147);
	Color3.fromRGB(246, 226, 172);
	Color3.fromRGB(255, 216, 185);
	Color3.fromRGB(238, 194, 168);
	Color3.fromRGB(220, 183, 139);
	Color3.fromRGB(243, 183, 141);
	Color3.fromRGB(231, 173, 134);
	Color3.fromRGB(228, 171, 132);
	Color3.fromRGB(205, 154, 119);
	Color3.fromRGB(202, 149, 117);
	Color3.fromRGB(214, 139, 98);
	Color3.fromRGB(204, 138, 111);
	Color3.fromRGB(196, 139, 105);
	Color3.fromRGB(198, 127, 90);
	Color3.fromRGB(180, 113, 81);
	Color3.fromRGB(164, 103, 74);
	Color3.fromRGB(147, 92, 65);
	Color3.fromRGB(134, 85, 60);
	Color3.fromRGB(165, 115, 88);
	Color3.fromRGB(152, 105, 81);
	Color3.fromRGB(142, 100, 77);
	Color3.fromRGB(134, 85, 60);
	Color3.fromRGB(137, 58, 46);
	Color3.fromRGB(136, 65, 67);
	Color3.fromRGB(145, 52, 0);
	Color3.fromRGB(109, 68, 49);
	Color3.fromRGB(88, 53, 39);
	Color3.fromRGB(76, 46, 33);
	Color3.fromRGB(65, 39, 28);
}

local randomSkinColor = skinColors[math.random(1,#skinColors)]



bodyPart.Color = randomSkinColor

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.