I just finished making a script that causes a neon part to turn white when a song hits a loudness of 350 (Usually the beat). It works just as I have planned and the script is pretty basic. The one problem I am having is that It is set to affect a part called "Flicker" but whenever I copy and paste another one of these parts it only affects the original one. How do I make my Script affect every part with the name "Flicker"?
while true do wait() if game.Workspace.TrelloSound.PlaybackLoudness > 350 then game.Workspace.Flicker.BrickColor = BrickColor.new("White") else game.Workspace.Flicker.BrickColor = BrickColor.new("Gold") wait() end end
Personally I would use aFor Loop
to loop through and find all the objects you want with whatever specific functions you want. I would put these "Clones"
in a model to make it easier and more clean. In my example I would do that.
Code:
while true do --Wouldn't recommend using a while loop unless you absolutely need to, but I don't know anything more to help you prevent using this wait() if game.Workspace.TrelloSound.PlaybackLoudness > 350 then for i,v in pairs(game.Workspace.Clones:GetChildren()) do --The model is named "Clones" if v.Name == "Flicker" then v.BrickColor = BrickColor.new("White") end end elseif game.Workspace.TrelloSound.PlaybackLoudness < 350 then --Added in another check, didn't realize I didn't do that for i,v in pairs(game.Workspace.Clones:GetChildren()) do if v.Name == "Flicker" then v.BrickColor = BrickColor.new("Gold") end end end end
If you have any problems or questions don't be afraid to comment and I would be glad to help. If this helped you don't forget to accept my answer. Also note that if you want to keep the parts in Workspace
then just change it to your wantings.