Part colour changes and then stops (playbackloudness)

Hi there, I followed a tutorial online and modified the script so that the colour ranges instead of just changing between two, however the issue is that it changes at the start of the music and then stops. I don’t really have an attempt apart from changing brickcolor to color3.fromrgb.

game:GetService("RunService").RenderStepped:Connect(function()
	local part = script.Parent
	local loudness = workspace.Sound.PlaybackLoudness
	
	if loudness >= 100 then
		part.Material = "Neon"
		part.Color = Color3.fromRGB(9, 137, 207)
	else
		part.Material = "Neon"
		part.Color = Color3.fromRGB(4, 175, 236)
	end
end) 
1 Like

Does it show an error in the output?

1 Like

No, it does not.

1 Like

Is the sound being played from a server script or local script? I see that this is a local script.

The sound is played server, the script is local because playbackloudness reads of the client.

Yeah, and RenderStepped is exclusive to local scripts as well.

Have you printed the value of the property periodically? Is it possible it’s only going to 100 once?

1 Like

No, however I am unsure on how to do that.

What do you mean by “Is it possible it’s only going to 100 once”?

1 Like
  1. There’s no need to change the Material of the part as it’s Neon in both cases
  2. try to add a print after the loudness variable declaration
2 Likes
local sound = workspace:WaitForChild("Sound")
local part = script.Parent

sound:GetPropertyChangedSignal("PlaybackLoudness"):Connect(function()
	print(sound.PlaybackLoudness)
	if sound.PlaybackLoudness >= 100 then
		part.Material = "Neon"
		part.Color = Color3.fromRGB(9, 137, 207)
	else
		part.Material = "Neon"
		part.Color = Color3.fromRGB(4, 175, 236)
	end
end) 
1 Like

Nothing is printed in the console, also the color isn’t continuously changing to the music

I believe the song should be played from the client as PlaybackLoudness doesn’t replicate across the server/client boundary.

1 Like
local sound = workspace:WaitForChild("Sound")
local part = script.Parent
local rs = game:GetService("RunService")

rs.RenderStepped:Connect(function()
	print(sound.PlaybackLoudness)
	if sound.PlaybackLoudness >= 100 then
		part.Material = "Neon"
		part.Color = Color3.fromRGB(9, 137, 207)
	else
		part.Material = "Neon"
		part.Color = Color3.fromRGB(4, 175, 236)
	end
end) 

Turns out changed/getpropertychangedsignal are disabled for that property, RenderStepped should work as usual.

But then others wouldn’t hear the sound of my randomized playlist. I have other scripts that use playbackloudness in a local script, and read of a sound plays off the server

1 Like

Try the RenderStepped version above with the sound being played from a server script. I’ve added a print command which should display the value of the property every frame/every time RenderStepped is fired.

Nothing is printed nor does the floor change apart from the first frame

1 Like

I’ll send you a video on what I mean

Try using heartbeat instead of renderstepped.

I know what you mean, I’ve seen it before, PlaybackLoudness is an awkward property to work with (because it changes so frequently often multiple times per frame). So for performance reasons Roblox doesn’t seem to allow .Changed/:GetPropertyChangedSignal() to work in relation with it.