Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do you change particle size based of playbackloudness?

Asked by 5 years ago

(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.

2 answers

Log in to vote
1
Answered by 5 years ago
Edited 5 years ago

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

0
Thanks, i'll try it now JustSxript 36 — 5y
0
I dont know why but its not working, its not showing any errors but its doing noting, maybe you can try it, still thanks for trying to get the answer maybe edit it later on. Reply to this if its working fine for you. JustSxript 36 — 5y
0
Did you :Play() the Sound? Robloxian_Thinking 5 — 5y
0
Imma try doing that JustSxript 36 — 5y
View all comments (3 more)
0
not working JustSxript 36 — 5y
0
maybe we can try team create later on the day? JustSxript 36 — 5y
0
It looks like GetPropertyChangedSignal() doesn't work on the sound's PlaybackLoudness property, as well as IsPlaying and Playing. Might be a bug? I also noticed that I was only able to get GetPropertyChangedSignal() to work in a LocalScript. It might have to do with sounds in Workspace being played globally on every client, and not actually on the server. WillieTehWierdo200 966 — 5y
Ad
Log in to vote
0
Answered by 3 years ago
Edited 3 years ago

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

0
OR Mel_pro1 5 — 3y

Answer this question