How do I make a sound visualizer that changes colour?

I have a block that I want to change colour depending on how loud the music is. So like if it’s silent then it would be black and the louder it is the higher the shade of blue it will be.
I know it’s a lot to ask but can anyone just give me a code example for it?

You can use the PlaybackLoudness property, but be aware that it doesn’t replicate over the server-client boundary, so it might be a good idea to play the sound and listen for the change on the client.

There is some sample code here:

4 Likes
local ColorSilent = color3.fromRGB(255,0,0)
local ColorLoud = color3.fromRGB(0,0,255)

Part.Color = ColorSilent:Lerp(ColorLoud, Sound.PlaybackLoudness / 1000)
6 Likes