Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

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

Asked by 7 years ago

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
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  RubenKan 3615 — 7y

2 answers

Log in to vote
0
Answered by 7 years ago

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.

Ad
Log in to vote
0
Answered by
Goulstem 8144 Badge of Merit Moderation Voter Administrator Community Moderator
7 years ago
Edited 7 years ago

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

Answer this question