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

How to size a part according to music? [closed]

Asked by 5 years ago

Say that you have a part. How would you change some of it's Vector3 values (i.e. changing the Y Axis of the size for the part with the music being played). Sort of like audio visuals. Thanks.

0
do you have any attempts? User#19524 175 — 5y
0
Usually values are changed by using the = operator. User#25115 0 — 5y
0
Which value are you aiming at doing this with: PlaybackLoudness, Volume, Pitch, etc.? DeceptiveCaster 3761 — 5y

Closed as Non-Descriptive by zblox164, IcyEvil, yHasteeD, 1TheNoobestNoob, DeceptiveCaster, and Lugical

This question has been closed because its title or content does not adequately describe the problem you are trying to solve.
Please ensure that your question pertains to your actual problem, rather than your attempted solution. That is, you were trying to solve problem X, and you thought solution Y would work, but instead of asking about X when you ran into trouble, you asked about Y.

Why was this question closed?

2 answers

Log in to vote
4
Answered by 5 years ago

Alrighty, so this is actually pretty simple. All you would have to do is use PlaybackLoudness to resize the part. Here is an example.


local part = workspace:WaitForChild('Part'); local sound = part:WaitForChild('Sound'); part.Anchored = true; while wait() do part.Size = Vector3.new(5,sound.PlaybackLoudness/5,5); end
Ad
Log in to vote
0
Answered by 5 years ago

Roblox Has The Same thing and they do it with guis too. Here is my script it uses four different ones and makes it look like a sound wave while playing an audio I made!

-- to be placed in StarterPlayer > StarterPlayerScripts

local Players = game:GetService("Players")
local LocalPlayer = Players.LocalPlayer
local bar1 = game.Workspace.AudioSpectrum.Part1
local bar2 = game.Workspace.AudioSpectrum.Part2
local bar3 = game.Workspace.AudioSpectrum.Part3
local bar4 = game.Workspace.AudioSpectrum.Part4
local bar5 = game.Workspace.AudioSpectrum.Part5
local bar6 = game.Workspace.AudioSpectrum.Part6
local bar7 = game.Workspace.AudioSpectrum.Part7
local bar8 = game.Workspace.AudioSpectrum.Part8
local sound = Instance.new("Sound")
local maxLoudness = 75000

bar1.Size = Vector3.new(1, 1, 1)
bar2.Size = Vector3.new(1, 1, 1)
bar3.Size = Vector3.new(1, 1, 1)
bar4.Size = Vector3.new(1, 1, 1)
bar5.Size = Vector3.new(1, 1, 1)
bar6.Size = Vector3.new(1, 1, 1)
bar7.Size = Vector3.new(1, 1, 1)
bar8.Size = Vector3.new(1, 1, 1)
sound.SoundId = "rbxassetid://2420742510"
sound.Looped = true
sound:Play()
sound.Parent = game.Workspace.AudioSpectrum
sound.Volume = 1
sound.PlaybackSpeed = 1.1 

while true do
    local amplitude = math.clamp(sound.PlaybackLoudness / maxLoudness, 0, 0.5)
    bar1.Size = Vector3.new(0.5, amplitude * 5000, 0.5)
    wait(0.0000001)
    bar2.Size = Vector3.new(0.5, amplitude * 4000, 0.5)
    wait(0.0000001)
    bar3.Size = Vector3.new(0.5, amplitude * 6000, 0.5)
    wait(0.0000001)
    bar4.Size = Vector3.new(0.5, amplitude * 3000, 0.5)
    wait(0.0000001)
    bar5.Size = Vector3.new(0.5, amplitude * 4000, 0.5)
    wait(0.0000001)
    bar6.Size = Vector3.new(0.5, amplitude * 5000, 0.5)
    wait(0.0000001)
    bar7.Size = Vector3.new(0.5, amplitude * 2000, 0.5)
    wait(0.0000001)
    bar8.Size = Vector3.new(0.5, amplitude * 5000, 0.5)
    wait(0.0000001)
end