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

Why is part only changing color to red and black?

Hi, i am trying to make a random button which changes color of a part, but the colors only appear black and red. i expected blue and colors i put in.

here is my script:

local mATH1 = {}
mATH1[1]= 255, 0, 0
mATH1[2]= 0, 255, 0
mATH1[3]= 255, 255, 0
mATH1[4]= 0, 0, 255
mATH1[5]= 255, 0, 255
script.Parent.MouseButton1Click:Connect(function()
 		game.Workspace.LightRGB1.Color = Color3.fromRGB(mATH1[math.random(1,5)])
		game.Workspace.LightRGB2.Color =  Color3.fromRGB(mATH1[math.random(1,5)])
		game.Workspace.LightRGB3.Color =Color3.fromRGB(mATH1[math.random(1,5)])
		game.Workspace.LightRGB4.Color =Color3.fromRGB(mATH1[math.random(1,5)])
		game.Workspace.LightRGB5.Color = Color3.fromRGB(mATH1[math.random(1,5)])
		game.Workspace.LightRGB6.Color =Color3.fromRGB(mATH1[math.random(1,5)])
		game.Workspace.LightRGB7.Color = Color3.fromRGB(mATH1[math.random(1,5)])
		game.Workspace.LightRGB8.Color = Color3.fromRGB(mATH1[math.random(1,5)])
end)

1 comment

0

It's a " Color3 " problem, For me: I only used lower numbers and it worked just as I want it e.g: (0.1, 0.1, 0) -- A different color

1 answer

✓ Accepted answer

For each color value, you need to place your RGB colors in a Color3.fromRGB(). Right now you're only setting it to the first number, which is red (255) or black (0).

mATH1[1]= 255, 0, 0

should be

mATH1[1]= Color3.fromRGB(255, 0, 0)

and so on.

1 comment

0

Thank you

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