PlaybackLoudness Lights

  1. I’m attempting to edit this script that I found via a youtube video so that it will control the enabled state of point lights. It currently uses PlaybackLoudness to change the color of a part.

  2. I cannot seem to edit the script so that it 1, controls the point light in question, and 2, controls the enabled state of said light.

  3. I’ve tried changing the BrickColor variable to Color3, as well as changing “TEST” and “P” to the titles of the part (“P” in this case) to PointLight, and “TEST” to the name of the part.

The current explorer, if this is of any assistance:

Script:

game:GetService("RunService").RenderStepped:connect(function()
	local loudness = game.workspace.Music.PlaybackLoudness
	
	if loudness >= 200 then 
		game.workspace.TEST.P.BrickColor = BrickColor.new "Industrial white"
	else
		game.workspace.TEST.P.BrickColor = BrickColor.new "Really black"
	end
end)

Try changing the color and brightness of the point light.

2 Likes

Just attempted this, it left me with the light stuck colored black and never flashing.

Then your threshold is probably not being met. Try lowering it from 200 to something like 100.

Hello @luvlorns! So after reviewing the code and messing around with it a bit, I believe I have come up with a viable solution. This code (see below) makes both the BrickColor and the PointLight’s Color change based off of the PlaybackLoudness.

 game:GetService("RunService").RenderStepped:connect(function()
     local loudness = game.workspace.Music.PlaybackLoudness

     if loudness >= 200 then 
	     game.workspace.TEST.P.BrickColor = BrickColor.new "Industrial white"
	     game.Workspace.TEST.P.PointLight.Color = Color3.new(1, 1, 1)
     else
	     game.workspace.TEST.P.BrickColor = BrickColor.new "Really black"
	     game.Workspace.TEST.P.PointLight.Color = Color3.new(0, 0, 0)
     end
 end)

And here’s a picture of my current Explorer (see below).

If you have any questions/concerns, feel free to let me know! :smiley:


Edit: Accidentally included an unneeded variable in the original code, so I changed it. :slight_smile:

1 Like

Thank you! The script works flawlessly :slight_smile:

1 Like