So I have a while wait() do loop because thats the only way that can run this PlaybackLoudness code (I think), and I want to be able to have it so when you click it, it turns on that color and fades with the beat. But when you click it again, it just turns to black, how would I do that? Heres the code:
local music = game.Workspace.Sound
script.Parent.MouseButton1Click:Connect(function()
local player = game.Players.LocalPlayer
local bracelet = player.Character.Bracelet2
while wait() do
bracelet.Color = Color3.new(music.PlaybackLoudness/255, music.PlaybackLoudness/0, music.PlaybackLoudness/0)
end
end)

1 comment
Most of the time, you should not connect events in a loop. Also, break is for loops, not return.