✓ Accepted answer
Try this on for size. Put this in a LocalScript in StarterPlayerScripts. Also make sure to set the sound and fire variables to point to the right places in your Workspace.
local sound = game.Workspace.Sound
local fire = game.Workspace.Part.Fire
while true do
if sound.IsPlaying then
local number = (sound.PlaybackLoudness / 80) * (1 + sound.Volume)
print(number)
fire.Enabled = true
fire.Size = NumberSequence.new(number)
fire.Speed = NumberRange.new(number + 10)
else
fire.Enabled = false
end
wait()
end
I found that using a regular Script wasn't able to read the changes in the sound's PlaybackLoudness, IsPlaying, Playing and TimePosition properties. This might be due to the sound actually being played on the client, even though the sound itself is in Workspace.
Also, the Changed event and the GetPropertyChangedSignal method did not work on PlaybackLoudness, IsPlaying, Playing or TimePosition. I wonder if this is a bug or some intentional behavior in the Roblox engine.
3 comments
Is this an audio visualizer? If so, this might help: https://www.youtube.com/watch?v=DP8cLUGl92o&list=PLLRkkym6t76GdWcD8hO0dVaBUJKZxFcSU&index=11&t=0s
Are you using a server script?
PlaybackLoudnessreturns 0 always on the server. You have to do it on a local script.Also did you consider
loudness / 1000makes a number to small where subtracting it from0.5essentially leaves you with a number almost exactly0.5?