Using PlaybackLoudness to sync Transparency to Sound

I’m trying to ‘sync’ a part’s transparency to the PlaybackLoudness of a Sound, but after searching around I couldn’t find a proper solution. As an example, the higher the PlaybackLoudness value is, the less transparent the part will be. The code below does not have any effect to the part for some reason

local sound = workspace.Music
local part = script.Parent

while true do
wait()
	part.Transparency = 1 - (sound.PlaybackLoudness / 1000)
end
1 Like

Is the transparency consistently 1? If so, are you running this code from the server? If so then that’s your problem, the server always sees a PlaybackLoudness of 0. The server has no concept of sound. Run this from a LocalScript and then modify your coefficients if needed to get the effect you want.

1 Like

PlaybackLoudness can’t be read by the Server. In case you are using a normal script instead of a LocalScript.

yes, the original script would have it stay as 1, but the script i posted here was slightly edited and seems to have no effect on the part, and it is a localscript inside the part i want to change

figured out the issue, i put the script in starterplayerscripts and it’s functional now.

1 Like

For future reference, you should check documentation and include more context such as the script type so it’d be easier to identify a problem. LocalScripts only run in certain locations.

1 Like