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

Can you make a bricks color and material change in sync with music?

Asked by 5 years ago

I am very new to scripting and this is what i'm trying to do. I'm trying to make a strobe light essentially, and i want the loudness of the music (Preferably the low end of the music) to trigger a switch in the color and material of the brick. The sound file is under workspace/MusicScript/S1

MusicScript is the script that is playing a playlist of songs, and S1 is the sound file.

In the workspace, i added a new script to try to make the light work, and this is the script

" game:GetService("RunService").RenderStepped:connect(function()

local loudness =  game.Workspace.MusicScript.S1.Volume




if loudness >= 350 then
    game.workspace.StrobeBrick.Material = "Neon"
    game.workspace.StrobeBrick.BrickColor = BrickColor.new  "Mid grey"

else

    game.workspace.StrobeBrick.Material = "Neon"
    game.workspace.StrobeBrick.BrickColor = BrickColor.new  "Really black"
end

end) "

Is there anything i'm missing? or any terms i've used wrong? Thank you!

1 answer

Log in to vote
0
Answered by 5 years ago

What you did wrong is you used the wrong property of the sound to get the loudness of it. If you simply change the last part of line 1 from Volume to PlaybackLoudness, it should work just fine. The volume property effects the loudness of the sound, but it doesn't return it.

0
Oh okay. I did try PlaybackLoudness ass well and it still didn't work, my friend said to use volume. So after both now working i decided to bring it here. I'll keep erring different things until it pulls through thanks for the comment DiploPlur -1 — 5y
0
Whoops, I forgot to say that it needs to be in a LocalScript in order for it to work. killer08932 149 — 5y
Ad

Answer this question