How do I make a part expand / shrink based on volume of sound

I want to make a boombox tool that expands when the music is loud and shrinks when the music is quiet. How would I achieve this?

1 Like

https://developer.roblox.com/en-us/api-reference/property/Sound/PlaybackLoudness

Does this solve your issue? Unfortunately, I don’t know how to use this property, but I know what it does.

Yes I know all about this property, I was just wondering how I can make the part expand / shrink to it.

Is it possible that you could just multiply the X, Y, and Z property of the part’s size?

Part.Size *= (Sound.PlayBackLoudness * extremity)

1 Like

Use TweenService.

local TweenService = game:GetService("TweenService")
local Boombox = --Path to boombox
local Sound = --Path to sound

Sound:GetPropertyChangedSignal("PlaybackLoudness"):Connect(function()
    TweenService:Create(Boombox, TweenInfo.new(0.25), {Size = Vector3.new(Sound.PlaybackLoudness, Sound.PlaybackLoudness, Sound.PlaybackLoudness)}):Play()
end)

Not quite sure why, but the tween isn’t playing

local OriginalSize = script.Parent.Mesh.Scale
local ts = game:GetService("TweenService")
script.Parent.ChildAdded:Connect(function(ch)
	if ch:IsA("Sound") then
		ch:GetPropertyChangedSignal("PlaybackLoudness"):Connect(function()
			local Multiplier = ch.PlaybackLoudness + 0.65
			local Tween = ts:Create(script.Parent.Mesh, TweenInfo.new(0.05), {Scale = Vector3.new(OriginalSize.X * Multiplier, OriginalSize.Y * Multiplier, OriginalSize.Z * Multiplier)})
			Tween:Play()
			wait(0.05)
		end)
	end
end)

Use size property instead, or learn how to configure it.