Alright; the reason it was probably rated “dumb” is because it’s using a Think hook, something ran every frame, to update the colors.

If this is for scoreboard flashing names; for example only for admins: put it in function PANEL:Think( ) at most.

Are you familiar with sine/cosine or other trigonometric functions? Are you familiar what other functions do in the code?

I’ll briefly explain, just in case. The sine wave is something that changes -1 to 1 in a smooth wave like function. I’m talking about wave in the literal sense, think of an ocean wave moving across a harbor, the wave doesn’t change in height / width but moves. The movement is along the x axis on a graph.

Depending on the value inside x assuming math.sin( x ), it will make the movement match up with a point on the graph. If you use CurTime( ) as x, or other time functions, you will see a very nice smooth ramp up and ramp down of color when applied to flashing names if done correctly. To make the change occur faster or slower, you multiply time by some number inside math.sin. Example: math.sin( CurTime( ) ) VS math.sin( CurTime( ) * 4 ). The first one would be slow-ish while the second would happen across -1 to 1 more rapidly. If you do it wrong, you’ll not see much change.

Remember the -1 to 1 piece of the puzzle? To change the height of the wave, think the wave is approaching closer to shore, multiply the entire thing. math.sin( Curtime( ) * 4 ) * 50; This allows it to travel from -50 to 50; a 100 unit distance in a smooth fashion. Now, a lot of people use math.abs, absolute value which ensures that only a positive value is returned, this reduces the range to 0-50, a 50 unit range and ensures the negative values are not returned into your function.

For example, say you want the color to go from 0 to 250, you could set the default color to 125 and multiply sin by 125 instead of 50 and then add it to the color value you wish to change; this will add, or subtract up to 125 to the color meaning you have a 250 range. You could possibly use 127.5 and get the full 255 range this way.

Alternatively, and easier to understand as a beginner to sin, multiply math.sin by 255, instead of 50 we talked about before, wrap it in math.abs which prevents - values from being used, and set that as the color you want to change.

This is what the code you provided does except in the instance where I used a multiplier of 4 with time, it uses 2:

[lua]local glow = math.abs(math.sin(CurTime() * 2) * 255);

flashingRed = Color(glow, 0, 0, 255)[/lua]

flashingRed refers to a dynamic color, something that will range from BLACK, 0,0,0,255 to RED, 255, 0,0,255

Have to help a neighbor real quick; if you have any more questions, please ask and please post the code that you’ve tried to integrate this into.