Why is this giving black as a color?

  1. I want the script to randomly choose a color from the color table.
  2. The color, black, returns even though it’s not in the table.
  3. Used a function, tried Color3.fromRGB, etc.
local Colors = {Color3.new(255/255, 0/255, 0/255), Color3.new(255/255, 110/255, 0/255), Color3.new(255/255, 255/255, 0/255), Color3.new(0/255, 255/255, 0/255), Color3.new(0/255, 156/255, 255/255), Color3.new(200/255, 0/255, 255/255), Color3.new(255/255, 50/255, 255/255)}

local function generate()
    return Colors[math.random(1, #Colors)]
end

while true do
    for i, v in pairs(script.Parent:GetDescendants()) do
        if v:IsA("Part") then
            local c = generate()
            v.Color = c
            print(c)
            v.Transparency = 0
            v.Material = "Neon"
        end
    end
    wait(1)
end

Please help, thanks!

I simply copied and pasted your code into a blank studio place and it seems to be working perfectly. Maybe some other script is affecting your model? Try it in a blank place and see if that works. Also check your output, it should be outputting things other than 0,0,0
2021-02-26_17-10-20

I don’t have any other scripts in that model, and it seems to not be working. I will try a blank baseplate now.

Yeah, it is. I’ll try to find the issue. Thanks!

1 Like