Let’s say that there is music/sound emitting from a part. The louder the music gets, the bigger the part gets, the quieter it gets, the smaller it gets. Something like this.
How would I do this?
Let’s say that there is music/sound emitting from a part. The louder the music gets, the bigger the part gets, the quieter it gets, the smaller it gets. Something like this.
How would I do this?
I have not made anything like this before, but I would assume it would use a sound’s PlaybackLoudness
property.
https://developer.roblox.com/en-us/api-reference/property/Sound/PlaybackLoudness
Made a mistake, and read your topic incorrectly.
Edit, just to avoid flooding the replies:
Have you looked at the example demonstrated in the wiki that sort of does what your asking for but with a Frame
instead? Maybe you could somehow apply that to a Part
.You could find it in the same link @P1X3L_K1NG attached to his post btw. (The docs’ similar demonstration is located downwards, from the link he provided)
@CrownedH20
You would have to do something like this.
local OriginalSize = Vector3.new(1,1,1) -- Change to the part's original size
local MaximumSize = 1 -- Change it to whatever
local Sensitivity = 100 -- How higher, how smaller the part gets
local Clamp = math.clamp(Sound.PlaybackLoudness/Sensitivity, 0, MaximumSize)
Part.Size = Vector3.new(Clamp, Clamp, Clamp) + OriginalSize
(Put the code into a LocalScript, in StarterGui.)
As other people have said, PlaybackLoudness should be read from the client.
Here is an open source sample place where it is used:
so something like this right? because it isn’t working. song plays but part doesnt change size.
local OriginalSize = Vector3.new(1,1,1) – Change to the part’s original size
local MaximumSize = 1 – Change it to whatever
local Sensitivity = 100 – How higher, how smaller the part gets
local Clamp = math.clamp(workspace.AudioVis.Sound.PlaybackLoudness/Sensitivity, 0, MaximumSize)
workspace.AudioVis.Size = Vector3.new(Clamp, Clamp, Clamp) + OriginalSize
also sorry for such a late response.
Are you doing this in a server-script or in a localscript?
You have to do it in a localscript, since the server can’t read Sound.PlaybackLoudness
. Put a localscript inside of “StarterGui” or “StarterPlayerScripts”.
If you’ve already done that, let me know if you have any errors aswell. Also, you should probably change MaximumSize = 1
to MaximumSize = math.huge
just to see if it’s not just the MaximumSize being too low.
ok so heres the new script, it isnt working
local OriginalSize = Vector3.new(1,1,1) – Change to the part’s original size
local MaximumSize = math.huge – Change it to whatever
local Sensitivity = 100 – How higher, how smaller the part gets
local Clamp = math.clamp(workspace.AudioVis.Sound.PlaybackLoudness/Sensitivity, 0, MaximumSize)
workspace.AudioVis.Size = Vector3.new(Clamp, Clamp, Clamp) + OriginalSize
its a localscript, inside starterplayerscripts, and yes, i have tried putting it in startergui.
You need to put the “Clamp” variable and the line that updates the size inside a loop
True, or else the PlaybackLoudness
stays at 0. So like this. (Inserted a loop, basically made the script for you.)
local VisualizerSettings = {
OriginalSize = Vector3.new(1, 1, 1);
MaximumSize = math.huge;
Sensitivity = 100
}
game:GetService("RunService").RenderStepped:Connect(function()
local Clamp = math.clamp(Workspace.AduioVis.Sound.PlaybackLoundess/VisualizerSettings.Sensitivity, 0, VisualizerSettings.MaximumSize)
workspace.AudioVis.Size = Vector3.new(Clamp, Clamp, Clamp) + VisualizerSettings.OriginalSize
end)
Unfortunately, From All I’ve Seen, Anything involving something like this seems to have to be a LocalScript put in a starter folder or something, Due to not being able to be fired on a server.