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
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
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.
place a part in workspace named ‘Part’
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.
Insert a script inside of the part
Place the code inside of the script that you just inserted.
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