Hello!
I’m working on a visualizer, but for some reason it’s not sizing. No errors in the output too. Here’s the sizing code that I wrote.
local firstLoop = coroutine.wrap(function()
--
runService.RenderStepped:Connect(function()
local firstAmplitude = (math.clamp(visualizerSound.PlaybackLoudness/50, 0, math.huge))
if currentRigType == ("R6") then
-- R6
visualizerPart.Size = (Vector3.new(0.05, firstAmplitude, firstAmplitude))
visualizerPart.CFrame = CFrame.new(currentTorso.CFrame.X, currentTorso.CFrame.Y -2.9, currentTorso.CFrame.Z)
elseif currentRigType == ("R15") then
-- R15
visualizerPart.Size = (Vector3.new(0.05, firstAmplitude, firstAmplitude))
visualizerPart.CFrame = CFrame.new(currentTorso.CFrame.X, currentTorso.CFrame.Y -1.6, currentTorso.CFrame.Z)
end
end)
end)
firstLoop()
So the loop does work, since the part does indeed follow the player meaning that the visualizerPart.CFrame does indeed work in the loop. It’s just the sizing that for some reason won’t work.
You don’t need to put it in a coroutine, events already run asynchronously. Print firstAmplitude and see what exactly it comes out as.
1 Like
It’s the sound’s playbackloudness. For some reason it stays on 0. I’ll try making a sound instance instead of a variable.
This is a LocalScript I assume?
No, it’s a serverscript that requires a converter, allowing it to read client data and properties. I know it’s weird but that’s not the issue.
I fixed it by changing the variable to an instance. The issue was that the variable was leading to the non-clone version of the sound.
I beg to differ. RenderStepped only works in LocalScripts according to documentation.
As RenderStepped is client-side only, it can be used in a LocalScript
or a ModuleScript
required by a LocalScript.
I also can’t find any documentation for it, but if I remember right, a lot of the properties of Sounds don’t work on the server including PlaybackLoudness.
The server does not have an audio device, it will see PlaybackLoudness as zero.
Whatever though, so long as you fixed it then I guess this is all irrelevant.
1 Like
I know it’s weird but the converter basically allows the server script to read client data. RenderStepped is basically every frame of the client, and since the server script reads it, it can use it.