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

How do audio visualizers work and how can I make one?

I'm not asking for a script what so ever, I'm just trying to learn how they work and how I can make one my self.

I'd like to be able to make one using a SurfaceGui and a Part changing size.

1 answer

✓ Accepted answer

Audio visualizers work by using the PlaybackLoudness property of a sound. One way you could make a vizualizer would be to make a ScreenGui + Frame and set the frame's size every RenderStepped to the PlaybackLoudness of the sound. A script would look something like this

local sound = workspace.Part.Sound
local frame = script.Parent

game:GetService("RunService").RenderStepped:Connect(function()
	frame.Size = UDim2.new(1,0,0,sound.PlaybackLoudness/2)
end)
-- you can change the "PlaybackLoudness/2" to anything different (even *2!)

If you wanted it to be a part, then it would get a little complicated because you would have to change the Size and CFrame properties

local part = workspace.Part
local sound = part.Sound
local normCF = part.CFrame
local offset

game:GetService("RunService").RenderStepped:Connect(function()
	workspace.Part.CFrame = normCF
	
	offset = sound.PlaybackLoudness/40
	
	workspace.Part.Size = Vector3.new(1,offset,1)
	workspace.Part.CFrame = CFrame.new(0,offset/2,0)
end)

13 comments

0

Thank you, Would it be the same for a Part using Part.Size?

0

well in that case, you will change the part's size but also need to change the position at the same time

0

ALSO, change the UDim2.new to Vector3.new (and use 0, sound.PlaybackLoudness/2, 0)

0

ok, also as its a function its self does it start doing this on join or can i make run server a variable and do it on something like mouse click or on touch

0

RunService is, well, a service. If you want it to start on a function then you could put it in a function (make sure there's a debounce so the player doesn't start the function a million times!)

0

basically script.Parent.MouseButton1Click:Connect(function() The script you provided end) I should be able to do that correct?

0

Ok sent that before i read that message, Thank you!

0

I also added the script for if it was a part

0

I see it can only be ran from a localscript. Where should the localscript go? And will it be the same for all players?

0

Nvm StarterPlayerScripts

0

you can also put it in Backpack, StarterGui, StarterPlayerScripts, and StarterCharacterScripts (I think)

0

Thank you, Also I know i've been asking alot, LIKE ALOT, but is there way I can move the current camera to the audio as well? Sorta like shaking it

0

I should be good using the audio to move the screen, but I don't know how the move the screen camera in the first place

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