So I'm trying to use the new PlaybackLoudness feature on a game. The problem is, is the transparency of the part ("Light") is changing to 0.1. It only seems to change to whatever I set it to using ((Sound/1000) + 0.1) and I'm not sure how to do this. I'm very unfamiliar with this and can't figure it out. Can someone help? Thanks!
Script:
local Sound = game.Workspace.Music.PlaybackLoudness local Part = script.Parent local x = ((Sound/1000) + 0.1) while true do wait(0.001) Part.Transparency = x end
What I did to let it work:
Script 1:
local Sound = game.Workspace.Sound Sound:Play() local Part = script.Parent while true do local x = script.Parent.Value.Value/1000 + 0.1 print (x) wait(0.001) Part.Transparency = x end
Script 2:
while true do wait() script.Parent.Value.Value = workspace.Sound.PlaybackLoudness end
Don't forget to add a NumberValue called Value in the Part to make this work.
If it is a number out of a thousand, it is still between 0 and 1. You can just directly set the Transparency as the PlaybackLoudness property.
Also, if you assign the 'Sound' variable outside of the while loop, it will never update. Index the PlaybackLoudness property inside of the loop.
local Sound = workspace.Music.PlaybackLoudness local Part = script.Parent while wait() do Part.Transparency = Sound.PlaybackLoudness; end