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

I want to change this parts RGB in less code any suggestions?

Can someone help me with making this code shorter to change the RGB of a part? Here's the code:

local part = script.Parent

while true do

part.Color = Color3.fromRGB(0, 45, 255)

wait(2)

part.Color = Color3.fromRGB(213, 231, 0)

wait(3)

part.Color = Color3.fromRGB(12, 43, 123)

wait(2)

end

Does someone have any suggestions?

1 comment

0

I don't think you can shorten this code any more since there are different wait periods and color combinations, and this seems pretty short already.

2 answers

✓ Accepted answer

If you're planning on adding more random colors to your part, then it might good to put all of the colors inside a table along with the delay, and have the program iterate through the whole table.

local part = script.Parent
local values = {
	{color={0, 45, 255},delay=2},
	{color={213, 231, 0},delay=3},
	{color={12, 43, 123},delay=2}
}

while true do
	for i = 1,#values do
		local data = values[i]
		part.Color3 = Color3.fromRGB(unpack(data.color))
		wait(data.delay)
	end
end

If you're not however, then you can just keep the code you already got.

so is it just to color it or do you actually want it changing in game? If you want it changing in game you can make a function for it.

1 comment

0

I'm just running it as a test. I don't need to do it in game!

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