Scaling Ball/Sphere when using PlaybackLoudness scales it down to "0.001, 0.001, 0.001"

Hi there, I have a script that visualizes a sphere to the music. I have used playbackloudness, the issue is, is that I can’t resize all the dimensions. In this case, the ball scales down to 0.001 and stays like that. It works fine when used on a normal part (cube, etc). Check the last lines.

Thanks!

local part = Instance.new("Part",game.Workspace)
local by = Instance.new("BodyVelocity",part)
local sound = Instance.new("Sound",part)

part.Size = Vector3.new(1,1,1)
part.Position = Vector3.new(0, 10, 0)
part.Color = Color3.fromRGB(255, 255, 255)
part.Material = Enum.Material.Neon
part.Shape = Enum.PartType.Ball
part.Anchored = false
part.CanCollide = false
part:SetNetworkOwner(nil)

by.MaxForce = Vector3.new(999999999999,999999999999,999999999999)
by.Velocity = Vector3.new(0,0,0)

sound.Name = "Audio"
sound.SoundId = "rbxassetid://280225750"
sound.Looped = true
sound:Play()

while wait() do
	part.Size = Vector3.new(sound.PlaybackLoudness/5, sound.PlaybackLoudness/5, sound.PlaybackLoudness/5);
	wait(0.001)
end

Why are you using a BodyVelocity when it’s set to 0,0,0? Is the ball supposed to be moving?
If it isn’t (since you’ve already made it CanCollide false and it won’t react to other Parts in the game) why not just Anchor it?
Are you getting any errors in your Output window when the size gets that low? If the sound.PlaybackLoudness gets to 0 then 0 divided by 5 will probably error.

You could make a simple change like this to make sure that it’s never 0:
volume = sound.PlaybackLoudness + .1
Then have:

while wait() do  --you could use task.wait() 
	part.Size = Vector3.new(volume/5, volume/5, volume/5);
	--wait(0.001) Wait isn't below 1/60th of a second (.0167) since rendered frame rate is 1/60th of a second. You already have that in your first line of the loop.
end

task | Roblox Creator Documentation

So NetworkOwnership works and everyone else can also see the ball moving (using in Void Script Builder).

Also, I’m not getting any errors regarding to the script.

But if you don’t make the first line local part then it will be created in the workspace and if it’s Anchored it will be visible to everyone anyway.

Also, did my fix for the math part of your question work dealing with the size issue?

What about playbackloudness? Isn’t that local?

I wanted the visualizer to be visible for everyone in Void Script Builder, so I used NetworkOwnership however it only works on unachored parts. Also, what do you mean by “But if you don’t make the first line local part then it will be created in the workspace”? It’s already the first line.

Also, I will check if it fixes after the server outage.

take the local out of local part.

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

NotReplicated
This item is not replicated across Roblox’s server/client boundary.

maybe that helps

Yes, I am aware of that, which is why I added networkOwnership as stated in the script. Please read this comment I posted here.

I wanted the visualizer to be visible for everyone in Void Script Builder, so I used NetworkOwnership however it only works on unachored parts. Also, what do you mean by “But if you don’t make the first line local part then it will be created in the workspace”? It’s already the first line.

Had to set the playback speed to 0.25…I can’t even hear the pauses between the beats that fast. I don’t even recognize the last character.

OP; I recommend trying to use a normal part with a sphere mesh or a meshpart instead. That is unless you want the sphere to collide with anything.

maybe turn it into a local script

Then other players wouldn’t see it. I don’t think you’re getting my point here. I absolutely know that playbackloudness doesn’t work on the server and rather local, which is why I added NetworkOwnership so all players in the server can see it too.

I heard other people trying this too, but I wasn’t sure if you could change the colour and material with a mesh shape. I’ll try it after the server outage is fixed.

PlaybackLoudness will always read 0 on the server. 0.001 is the minimum size for any part therefore it sets to that instead of 0.

Are you 100% sure that is the case. I made something similar and I didn’t need a local script to get the playback loudness. Also, I believe that this works for normal parts except the sphere

OP: You can change MeshParts with Surface appearance. I am pretty sure ypu can change the Material too.

Honestly, I wanted to confirm myself before sending but… roblox is doing not alive rn.

1 Like

Not repeating twice you may need a local script since sounds are localized by local scripts.

Did it involve remotes, networkOwnership, etc? I saw a couple of people who made their own in Void Script Builder.

also, roblox is back up.

This time, the size shows as “0.002, 0.002, 0.002”. Possibly the “volume” would’ve changed it. The sphere doesn’t move still. I’ll change it to a mesh type.

Also, this line here changed the size a bit. When I change it to 1 instead of .1, the size changed but nothing happened other than that.

volume = sound.PlaybackLoudness + .1