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

Why is part only changing color to red and black?

Asked by 4 years ago

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)

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 NickAtNick 163 — 4y

1 answer

Log in to vote
0
Answered by
megukoo 877 Moderation Voter
4 years ago
Edited 4 years ago

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.

0
Thank you Error_404isGAMING 30 — 4y
Ad

Answer this question