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

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

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

✓ Accepted answer

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.

2 comments

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

0

Whoops, I forgot to say that it needs to be in a LocalScript in order for it to work.

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