Hi, so I've been working at this for about an hour trying to fix or figure out why it doesn't work... I definitely need some help from someone else.

What I'm trying to make is a script that makes every part named raveFloor turn into a random color from the rainbow. It's supposed to not be able to have the same color for more than one cycle, but I'm seeing colors still repeat themselves when I test them... Please, help. (And if you want extra fun points, suggest a better indigo; it just looks gray.) If I can improve anywhere else in the script, please tell about that as well :)

Here's my code

--[[

this script makes whatever is named "raveFloor" just go into a rave mode,
randomly choosing a color and making said part that color

--]]

local victim = "raveFloor";
-- this is what you name anything you want to rave

local noLoops = 0;
-- just made for makin sure theres not the same color :)

local folder = game:FindFirstChild("PartsHolder",true)
-- finds the partsholder folder for performance

local num = 0;

local function RAVE(part)
	num = math.random(1,7);
	-- random rolly 1-7
	
	if (num == 1) then
		if(noLoops == 1) then
			RAVE(part)
		else
			part.BrickColor = BrickColor.new(1,0,0)
			-- red
			noLoops = 1
		end
	end 
	if (num == 2) then
		if(noLoops == 2) then
			RAVE(part)
		else
			part.BrickColor = BrickColor.new(1,.5,0)
			-- orange
			noLoops = 2
		end
	end 
	if (num == 3) then
		if(noLoops == 3) then
			RAVE(part)
		else
			part.BrickColor = BrickColor.new(1,1,0)
			-- yellow
			noLoops = 3
		end
	end 
	if (num == 4) then
		if(noLoops == 4) then
			RAVE(part)
		else
			part.BrickColor = BrickColor.new(0,1,0)
			-- green
			noLoops = 4
		end
	end 
	if (num == 5) then
		if(noLoops == 5) then
			RAVE(part)
		else
			part.BrickColor = BrickColor.new(0,0,1)
			-- blue
			noLoops = 5
		end
	end 
	if (num == 6) then
		if(noLoops == 6) then
			RAVE(part)
		else
			part.BrickColor = BrickColor.new(.67,.84,.9)
			-- indigo
			noLoops = 6
		end
	end
	if (num == 7) then
		if(noLoops == 7) then
			RAVE(part)
		else
			part.BrickColor = BrickColor.new(1,0,1)
			-- violet
			noLoops = 7
		end
	end
end


local function findParty(obj)
	for _, child in pairs(obj:GetChildren()) do	
		if (child.Name == victim) then		
			RAVE(child)		
		end
		findParty(child)	
	end
end

---------------------------------------------------------------------------------

while true do
	findParty(workspace)
	wait(.5)
end

2 comments

0

Why don't you just math.random the r, g, and b components of the BrickColor?

0

We only want those seven colors, not just random colors. However, we couldn't get the colors to stop repeating in the other script either..