I just made a script that changes a stringvalue using playback loudness. I have it set to randomize through the given colors and choose one to change the stringvalue into. I am trying to figure out how I can make it choose White if the playback loudness is greater than 250, and if not higher than 250 than it will go straight to gold. The stringvalue is the parent of the script.
1 | local color = { "Gold" , "Lily white" } |
2 |
3 | while true do |
4 | wait() |
5 | if game.Workspace.TrelloSound.PlaybackLoudness > 250 then |
6 | script.Parent.Value = color [ math.random( 1 ,#color) ] |
7 | wait() |
8 | end |
9 | end |
Make val a BrickColor Value.
01 | local color = { Gold = BrickColor.new( "Gold" ), White = BrickColor.new( "White" ) } |
02 |
03 | local sound = workspace:WaitForChild( 'TrelloSound' ) |
04 | local val = script.Parent |
05 | while true do |
06 | local volume = sound.PlaybackLoudness |
07 | -- ternary operator |
08 | val.Value = (volume > = 250 and color.White or color.Gold) |
09 | --[[ same as |
10 | if volume >= 250 then |
11 | val.Value = color.White |
12 | else |
13 | val.Value = color.Gold |
14 | end |
15 | --]] |
16 | wait() |
17 | end |