Colour changing block

i’m trying to make it so it grabs the name of a colour from a table and changes the parent to the colour, i don’t know what i’m doing wrong can anyone help me?

local colours = {"Really Red","Lime Green"}
local colourchanger = script.Parent

function colourloop()
	local randomEvent = colours[math.random(#colours)]
	colourchanger.BrickColor = BrickColor.new(randomEvent)
end

while true do
	colourloop()
	wait(0.5)
end
1 Like

That a really outdated way of making such a thing
Modernized example would be:

local colours:{Color3} = {Color3.new(1,0,0),Color3.new(0,1,0)}
local function colourloop():()
	colourchanger.Color = colours[math.random(1,#colours)]
end

while true do
	colourloop()
	task.wait(0.5)
end


If for some reason you want to go with BrickColor.new() just know that it can accept Color3,string,number or (number,number,number) to create a brick color.
BrickColor’s usecases in 2025 is mainly to tell name of a color and in actual code you should use Color3 hower some physics constraints like Rope or Rod requiring you to use BrickColor (no idea why and its probably a subject to change)

2 Likes

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