Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How do you change particle size based of playbackloudness?

2 answers

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

7 comments

0

Thanks, i'll try it now

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.

0

Did you :Play() the Sound?

0

Imma try doing that

0

not working

0

maybe we can try team create later on the day?

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.

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

1 comment

0

OR

This discussion is preserved as it was. New answers, comments, and votes are closed.