Lerp doesn't change the color of a part when transitioning between two colors using playbackloudness

Hi there, I have a script that uses lerp to transition between two colors using playbackloudness, however the color stays black (as what the first color is defined to) and doesnt change to the second. I’ve tried changing the number that divides playbackloudness however to no appeal there is no difference.

I’m sorry for those who have seen my activity of posting the same topic, but that’s the sheer determination to get it right.

Script below:

local sound = workspace:WaitForChild("Sound")
local part = workspace.parts["Club Floor"]

local ColorSilent = Color3.fromRGB(0, 0, 0)
local ColorLoud = Color3.fromRGB(10, 162, 243)
part.Color = ColorSilent:Lerp(ColorLoud, sound.PlaybackLoudness / 1000) 
1 Like

I’m assuming this is because sound.PlaybackLoudness is returning 0 which would result in the division calculating to 0 as well.

I’ll try lower the divisor then.

Divide it by 100. ignore

Doesn’t work. I tried printing the value from playbackloudness however there is no log in the output. Am I doing something wrong?

local sound = workspace.Sound
local part = workspace.parts["Club Floor"]

local ColorSilent = Color3.fromRGB(0, 0, 0)
local ColorLoud = Color3.fromRGB(10, 162, 243)
part.Color = ColorSilent:Lerp(ColorLoud, sound.PlaybackLoudness / 100) 
print(sound.PlaybackLoudness)

it’s fixed, it’s printing 0

Can only read PlaybackLoudness from a local script

0 divided by any number will be 0 is what I was inferring to.

It is a local script.

I’ll try printing playbackloudness before and see what happens

task.spawn(function()
	while task.wait() do
		print(sound.PlaybackLoudness)
	end
end)

still prints 0

I think there’s something wrong with playbackloudness itself, I’m not entirely sure.

It’s printing around 150-160

So if I’m dividing 150 by 1000, I’m getting around 0.15 so maybe the problem here is that the percentage is too low.

It was printing 0 before because you were only reading the value from the property once when the script first executes which is likely before the sound started playing.

Oh that was after, the script you gave me now was printing values.

local sound = workspace.Sound
local parts = workspace:WaitForChild("parts")
local floor = parts:WaitForChild("Club Floor")
local ColorSilent = Color3.fromRGB(0, 0, 0)
local ColorLoud = Color3.fromRGB(10, 162, 243)

sound:Play()

task.spawn(function()
	while task.wait() do
		floor.Color = ColorSilent:Lerp(ColorLoud, sound.PlaybackLoudness / 100)
	end
end)

So I did another test this time with the print after the execution and now its bumped up to 280-370

What does task do? I’ve seen the documentation however I don’t really understand it.

Alright, I did it and now it works, however the color is now changing blue to green as its second color.