Color of a part changing depending on the loudness of an audio

I know this topic has already been covered but everything everyone else has said doesn’t work for me. I don’t know if I’m doing something wrong or it’s just outdated.

What I want to achieve is a brick changing color based on the playback loudness of an audio.

For example if the audio is quiet the color would be (0, 0, 0) but if it’s really loud it would be at (0, 0, 200)

The script I tried:

local part = script.Parent
local Sound = game.Workspace.Sound
part.color = Color3.fromRGB(0,0,Sound.PlaybackLoudness/3.9)

I don’t know if I made any mistakes in it and I feel like it should work but it doesn’t

3 Likes

Make sure the part is constantly changing color, not just changing color once. You can do this using a loop:

local part = script.Parent
local Sound = workspace.Sound
Sound:Play()
while Sound.IsPlaying do
    part.Color = Color3.fromRGB(0, 0, Sound.PlaybackLoudness / 3.9)
    wait()
end
1 Like

You should update the color repeatedly, maybe

1 Like

It didn’t work, any other ideas?

hey once u get it working id like to see it, like club iris’s stage lights.

That’s exactly what I’m looking for. I’m not advanced enough to figure it out on my own yet

me either lol i cant script for a dime.

idea look thro the free models and copy one of their scripts that work

Can’t find any that work. I’ve tried multiple but maybe I’m just not looking hard enough

id type club iris might find the script inside the stollen parts.

i have found a solution and it’s by putting the script in a local script, since playback loudness don’t update in the server but instead the client.

I hope this helps!

I must’ve done something wrong because that didn’t work either. Can you tell me exactly what script you used and where it’s located?

did you parent the local script inside the part? because it won’t really work, it needs to be in the starter gui or starter folder

The script works regardless of being server/client I tested it works. You need to put the script inside of a part for it to work, and you need to have a sound inside of workspace named ‘Sound’. Since @RuleDefy isn’t aware of this I don’t think they know how to script so it’s best to instruct them on what they need to do in studio.

  1. place a part in workspace named ‘Part’
  2. place a sound into workspace named ‘Sound’. Give this sound a ‘SoundId’ by opening up View > Properties, and selecting the part to get it’s attributes.
  3. Insert a script inside of the part
  4. Place the code inside of the script that you just inserted.
  5. You should be good to go now.
2 Likes

no no no, PlaybackLoudness doesn’t update on server-side because each players have their own volume so PlaybackLoudness must be inside a client-side script. yes, you can play sounds inside a server script but you can’t update the playbackloudness inside a serverscript

I finally got it, thanks for the help!

1 Like

glad i could help!

This text will be hidden