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

How would you pass multiple values for a particle emitter?

Asked by
Wayyllon 170
4 years ago

Im trying to have a particle emitter get generally more violent when the playback loudness of an audio goes over a certain amount but i dont know how to pass multiple values into the particle emitter.

local PE = game.Workspace.FireThing1.ParticleBrick.ParticleEmitter
local NP = game.Workspace.NowPlaying
local V = game.Workspace.NowPlaying.Sooooooooong
local PE = game.Workspace.FireThing1.ParticleBrick.ParticleEmitter

game.Workspace.NowPlaying.ChildAdded:Connect(function()
    local sound = game.Workspace.NowPlaying:FindFirstChildWhichIsA("Sound")
    local PL = sound.PlaybackLoudness
    repeat
        PE.Lifetime = (1.5)(2.5)
        PE.Size = 7
        PE.Speed = 6
        PE.SpreadAngle = (10)(10)
        wait(.5)
        PE.Lifetime = (2.5)(3.5)
        PE.Size = 4
        PE.Speed = 5
        PE.SpreadAngle = (5)(5)
        print("I ran")
        wait(.5)
    until (V.Value == false)
end)

i tried this but it doesnt seem to work.

1 answer

Log in to vote
0
Answered by 4 years ago
Edited 4 years ago
-- fixed example of your code
local PE = game.Workspace.FireThing1.ParticleBrick.ParticleEmitter
local NP = game.Workspace.NowPlaying
local V = game.Workspace.NowPlaying.Sooooooooong
local PE = game.Workspace.FireThing1.ParticleBrick.ParticleEmitter

workspace.NowPlaying.ChildAdded:Connect(function()
    local sound = game.Workspace.NowPlaying:FindFirstChildWhichIsA("Sound")
    repeat
 local PL = sound.PlaybackLoudness
        PE.Lifetime = NumberRange.new(1.5,2.5)
        PE.Size = 7
        PE.Speed = 6
        PE.SpreadAngle = NumberRange.new(10,10)
        wait(.5)
        PE.Lifetime = NumberRange.new(2.5,3.5)
        PE.Size = 4
        PE.Speed = 5
        PE.SpreadAngle = NumberRange.new(5,5)
        print("I ran")
        wait(.5)
    until (V.Value == false)
end)
-- the playbackloudness method
local PE = game.Workspace.FireThing1.ParticleBrick.ParticleEmitter
local NP = game.Workspace.NowPlaying
local V = game.Workspace.NowPlaying.Sooooooooong
local PE = game.Workspace.FireThing1.ParticleBrick.ParticleEmitter

workspace.NowPlaying.ChildAdded:Connect(function()
    local sound = game.Workspace.NowPlaying:FindFirstChildWhichIsA("Sound")
    repeat
    local PL = sound.PlaybackLoudness
        PE.Lifetime = NumberRange.new(PL/485,PL/500) -- PL/whatever number you want, max "loudness" is usually around 500, you could also do some advanced math to do it based on song length and pitch
        PE.Size = PL/490
        PE.Speed = PL/480
        PE.SpreadAngle = NumberRange.new(10,10)
        print("I ran")
        wait()
    until (V.Value == false)
end)
Ad

Answer this question