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

Help With Playback Loudness Script?

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.

local color = {"Gold", "Lily white"}

while true do
	wait()
	    if game.Workspace.TrelloSound.PlaybackLoudness > 250  then
			script.Parent.Value = color[math.random(1,#color)]
		wait()
	end
end

1 answer

✓ Accepted answer

Make val a BrickColor Value.

local color = {Gold = BrickColor.new("Gold"), White = BrickColor.new("White")}

local sound = workspace:WaitForChild('TrelloSound')
local val = script.Parent
while true do
	local volume = sound.PlaybackLoudness 
	-- ternary operator
	val.Value = (volume >= 250 and color.White or color.Gold)
	--[[ same as
	if volume >= 250 then 
		val.Value = color.White
	else
		val.Value = color.Gold
	end
	--]]
	wait()  
end

1 comment

0

That isn't working for me. The parts are idle on lilly white

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