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

How can I make the lights flicker to the beat of a sound?

Hi I'm making a vibe game and I can't figure out how to make the lights turn on/off to the beat of the song. Just instructions or scripts would be helpful.

2 answers

✓ Accepted answer

PlaybackLoudness, tells you how loud the sound is within 0 to 1000. You can set the threshold loudness and turn on the lights.

local lights = {workspace.light0, workspace.light1}
local THRESHOLD_VALUE = 50
local sound

function playSound()
	-- play sound
end

while true do
	playSound()
	while sound.IsPlaying do
		if sound.PlaybackLoudness > THRESHOLD_VALUE then
			for _,v in pairs(lights) do
				v.Enabled = true
			end
		else
			for _,v in pairs(lights) do
				v.Enabled = false
			end
		end
	end
end

I don't recommend actually using the script. It might not even work. Its purpose is to tell you how to do it.

4 comments

1

Put a yield on the loop else it will crush the game

0

Good catch.

0

I tired putting the script in the light but it didn't work. Is there any specific thing I need to do like call the light light1 or light0?

0

Well, in the first line, change 'workspace.light0' to wherever your lights are. In line 3 point it to where your audio is. Fill in PlaySound() with a function that plays your sound (it does nothing in my script currently).

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