I have a Question about the Music! How to make a Part when the Music gets Louder that the Part goes Neon and when the Music gets quieter that the part goes to the normal color.
So the problem with a system like this is different sounds have different volumes, if you had a song that was a below average volume, the part may not turn neon enough, but if you had a song that was above average, it may turn neon too much.
This could be fixed if roblox added some property like “volume peaked” that turns true at the louder parts of the song, but they haven’t so you just have to guess what is a good threshold, or alternatively if you want, you can have a premade list of a bunch of music with different thresholds. But anyway, here’s a script that may help:
local sound = game.Workspace.Sound
game:GetService("RunService").RenderStepped:Connect(function()
if sound.PlaybackLoudness > threshold then
game.Workspace.Part.Material = Enum.Material.Neon
end
end)
Alternatively if you’re willing to play the song all the way through one time, you can take samples of the volume a bunch of times and then store the average volume the entire song, and from there make a script that checks how far above the average volume it currently is. If it’s above by a certain threshold, turn the part neon.
There’s two problems with this script, it assumes that the song isn’t at max loudness for the majority of the time, and at the beginning of the first playthrough of the song it’ll have an inaccurate average volume, but if you want to go with something like that then here’s a basic script for it:
local sound = game.Workspace.Sound
local totalVolume = 0
local samplesTaken = 0
totalVolume.Parent = sound
game:GetService("RunService").RenderStepped:Connect(function()
totalVolume += sound.PlaybackLoudness
samplesTaken += 1
local averageVol = totalVolume/samplesTaken
if sound.PlaybackLoudness > averageVol+threshold then
game.Workspace.Part.Material = Enum.Material.Neon
end
end)
PS: I didn’t test these scripts so they may not work but the concept is there and can definitely be done.