This is a ServerScript because on a LocalScript it didn't work either.
local sound = workspace.MusicHandler.Music sound.Changed:Connect(function() if sound.PlaybackLoudness >= 300 then script.Parent.BrickColor = BrickColor.Random() end end)
PlaybackLoudness is readonly. Changed will not fire unless a property is written to (correct me if I'm wrong). PlaybackLoudness only updates itself. Also note that Changed also does not fire in physics-related changes. You will need to look for changes constantly. I suggest using the Heartbeat event of RunService because PlaybackLoudness runs with the server. A while-true statement would also be fine.
local RunService = game:GetService("RunService") local sound = workspace.MusicHandler.Music RunService.Heartbeat:Connect(function() if sound.PlaybackLoudness >= 300 then script.Parent.BrickColor = BrickColor.Random() end end)
PlaybackLoudness will normally never be above 300 (unless the Volume is super loud.)
Try numbers like 10 and 20 to check the loudness.
Also, sound.Changed
may not occur when the PlaybackLoudness changes due to how often it can fluctuate. You may need to use a while loop to check it.
Example:
local sound = workspace.Sound sound:Play() while true do print(sound.PlaybackLoudness) wait(0.5) end