Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

I'm trying to use the PlaybackLoudness feature and I'm having problems, can someone help?

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

1 comment

0

You always set it to the same value. You should put --------x = (Sound/1000) + 0.1------------ inside the while loop, also, you'll have to use localscripts. -> video showing https://www.youtube.com/watch?v=-kqaPjNt1e8 

2 answers

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

This discussion is preserved as it was. New answers, comments, and votes are closed.