(I did put it in a local script)
local sound = workspace.Sound if sound.IsPlaying then script.Parent.Fire.Size = 0.5-((sound.PlaybackLoudness/1000)*1) end
Im trying to make the size 0.5 bigger based on playbackloudness but its not working, btw I have another question here: https://scriptinghelpers.org/questions/86786/how-do-i-change-the-brickcolor-based-on-playerbackloudness
Thanks for reading.
You should use WaitForChild in LocalScripts when referencing Instances (in case they didn't load yet when you're trying to use them):
local sound = workspace:WaitForChild("Sound")
Because the script only runs on startup, the Sound probably won't be playing, that's because you have to listen for when it starts playing, with the Changed event:
local sound = workspace:WaitForChild("Sound") local Fire = script.Parent:WaitForChild("Fire") sound:GetPropertyChangedSignal("IsPlaying"):Connect(function() while wait() do if sound.IsPlaying then local PlaybackLoudness = sound.PlaybackLoudness Fire.Size = 0.5 - (PlaybackLoudness / 1000) else break end end end)
By the way, the reason I'm using GetPropertyChangedSignal("IsPlaying") is because it's just a shorter replacement for
sound.Changed:Connect(function(PropertyName) if PropertyName == "IsPlaying" then ---the stuff above end end)
But, a simpler way of doing this is checking when the PlaybackLoudness itself changes, like this:
local sound = workspace:WaitForChild("Sound") local Fire = script.Parent:WaitForChild("Fire") sound:GetPropertyChangedSignal("PlaybackLoudness"):Connect(function() local PlaybackLoudness = sound.PlaybackLoudness Fire.Size = 0.5 - (PlaybackLoudness / 1000) end)
Then, your particle's Size changes each time the PlaybackLoudness gets changed, without any inefficient loops
workspace.part.ParticleEmitter.Size = NumberSequence.new(0.5 + workspace.Sound.PlaybackLoudness / 1000)
You can change the 1000 to something else like 100 or 10 or 500 but not over 1000
or you can do this
workspace.part.Fire.Size = math.random(0.5,10)+ workspace.Sound.PlaybackLoudness / 1000 The 10 is how big is the max size of the fire and 0.5 is how small it can get