How do I make the color changing using lerp smoother?

Hi there, I have a club floor that changes colors to the music’s loudness. The issue is, is that colors don’t move smoothly and rather does this “flickering” effect when changing in between colors. I’ve tried using tween however it’s an absolute pain working with it. Also, since this is using renderstepped, it runs at 60 frames per second however I’ve also tried it at 144fps (as prior to an fps unlocker) and didn’t cause much of a difference.

local sound = workspace.Sound
local plr = game.Players.LocalPlayer
local parts = workspace:WaitForChild("parts")
local floor = parts:WaitForChild("Club Floor")
local pillars = workspace.pillar

local pillar1 = pillars.Model1.neon.Part
local pillar2 = pillars.Model2.neon.Part
local pillar3 = pillars.Model3.neon.Part
local pillar4 = pillars.Model4.neon.Part

local button = plr.PlayerGui:WaitForChild("Settings"):WaitForChild("GUI"):WaitForChild("panels"):WaitForChild("ScrollingFrame"):WaitForChild("Visualizers"):WaitForChild("Club Floor"):WaitForChild("button")
local on = true

local ColorSilent = Color3.fromRGB(0, 0, 0)
local ColorLoud = Color3.fromRGB(10, 162, 243)

local rs = game:GetService("RunService")

local lastSoundLevel = sound.PlaybackLoudness

button.Text = ("ON")
button.BackgroundColor3 = Color3.fromRGB(90,90,90)

rs.RenderStepped:Connect(function()
	if on then
		local difference = (sound.PlaybackLoudness / 2.2) - lastSoundLevel

		difference /= 100

		difference = math.clamp(difference,0.62,1)
		
		local change = ColorSilent:Lerp(ColorLoud,difference)
		
		floor.Color = change
		
		pillar1.Color = change
		pillar2.Color = change
		pillar3.Color = change
		pillar4.Color = change
	end
end)

1 Like

You’re using black on one end and blue on the other, perhaps try picking two colors which are less dissimilar from one another, like light blue and dark blue for example.

The corresponding Color3 values would be.

Color3.new(0, 16, 176) -- dark blue
Color3.new(180, 210, 228) --light blue

Would changing this to HSV any different?

If you want smoother lighting stick to colors which are different shades of one another not entirely different colors altogether.

Alright. I’ll try your suggestion.

the reason it doesn’t look smooth is because you are getting the difference between the last frame and this frame and doing it by that. This can cause issues with very loud noises that don’t change volume look default. It can also look stuttery.

Instead of getting the difference of the volume try just doing the actual playback volume and lerping based off of that.

I don’t really see much of a difference. It seems as if dividing it by the actual loudness is a bit more flickery than before. I even divided it by 300 to prevent it from getting to any other color than blue.