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

How do I make a dance floor with specific colours?

How do I make a dance floor with specific colours? Here's my attempt:

 local colours = {
			"Really blue",
			"Deep orange",
			"New Yeller",
			"Bright green",
			"Really blue", 
			"Cyan",
			"Carnation pink", 
			"Eggplant",
			"White"
		}		        
		
		local randomColour = math.random(1,#colours)
		local Parts = game.Workspace.GameParts.unsafeParts:GetChildren()
		
		while true do
			for i,v in pairs(Parts) do
				if v:IsA("Part") then
					v.BrickColor = BrickColor.new(colours[randomColour])
				end
			end
		wait(4)
	end

2 comments

0

Why not use BrickColor.random

0

ok ill try and test

2 answers

✓ Accepted answer

Edited mines*

local Parts = game.Workspace.GameParts.unsafeParts:GetChildren()
local Colors = {
"Really red",
"Bright yellow",
"Bright blue"
}

while wait(4) do -- You can also do this for waiting
           for i,v in pairs(Parts) do
               if v:IsA("Part") then
		local Num = math.random(1, #Colors) -- Get a random number between 1 and the number of strings in colors
                   v.BrickColor = BrickColor.new(Colors[Num]) -- So if Num == 2, then it would change to bright yellow
               end
           end
   end

Hope this helps!

2 comments

0

Yeah but I want to use specific colours, not any random colour

0

I edited mines, you can retry it.

Alternatively, you could do this:

local colors = {
	BrickColor.new("Tawny"),
	BrickColor.new("Toothpaste"),
	BrickColor.new("Teal"),
	BrickColor.new("Terra Cotta"),
	BrickColor.new("Steel blue"),
}

local randomcolor = colors[math.random(1,#colors)]

local part = game.Workspace.Part
part.BrickColor = randomcolor

local Parts = game.Workspace.GameParts.unsafeParts:GetChildren()

while true do
	for i,v in pairs(Parts) do
		if v:IsA("Part") then
			v.BrickColor = BrickColor.new(colours[randomColour])
		end
	end
	wait(4)
end

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