How do I get a object to fade in one and colour to another based off playbackloudness?

Hi there, I have a script that changes a part to 2 different colours using tween, but I want to achieve so that this does it based off playbackoudness. What I’ve done already is to make at least the colours change, now I want to link this to playbackloudness. Another thing is that this is a serverscript that is under a part, however would it still work if I changed it to a local script under StarterGui?

local TweenService = game:GetService("TweenService")
local part = script.Parent
local TweeningInformation = TweenInfo.new(
	2,
	Enum.EasingStyle.Quad,
	Enum.EasingDirection.Out,
	753475938457843579348573,
	true,
	0
)

local PartProperties = {
	Color = Color3.fromRGB(33, 84, 185)
}

local Tween = TweenService:Create(part,TweeningInformation,PartProperties)
Tween:Play()
3 Likes

If you want to set the color of a part via PlaybackLoudness then tweening it is not efficient because PlaybackLoudness is a constant changing property. The way I always did this is with just some math

2 Likes

Although this isn’t an answer, I’d like to let you know that setting the tween repeat to a number like that to simulate infinity is bad practice. Please use -1 instead of 753475938457843579348573.

Oh? I would just put play in a while wait(2) do tween:Play end.

local TweenService = game:GetService("TweenService")
local part = script.Parent
local TweeningInformation = TweenInfo.new(
	2,
	Enum.EasingStyle.Quad,
	Enum.EasingDirection.Out,
	753475938457843579348573,
	true,
	0
)

local PartProperties = {
	Color = Color3.fromRGB(sound.PlaybackLoudness, 84, 185)
}

local Tween = TweenService:Create(part,TweeningInformation,PartProperties)
Tween:Play()

Sorry for a late reply but was too lazy to get back to you. Why is the colorRGB only 2 numbers instead of 3? It just displays as black in the script but doesn’t do anything to the club floor

PlaybackLoudness is only valid in the client. The colors will have to be changed from there.

Yeah I changed the script to a local script but it still ain’t changing nor does it still explain why it’s only two numbers for a color

Where is the script located in?

inside the object. I could put it to startergui also

LocalScripts don’t run inside the Workspace. Try putting in in StarterCharacterScripts.

1 Like

That’s true. Workspace can run normal scripts, (I kindaa… guess module scripts…?) and doesn’t run local scripts at all

I put it into startercharacterscripts. Still doesn’t work. Please answer my question before, “Why is there only two numbers for the Color3.fromRGB instead of 3?”

Here is my script:

Under StarterPack:

local part = -- Put your part path here. This value also supports table input.
while wait(0.01) do
	for i = 1, #children do
		children[i].Color = Color3.fromRGB(math.floor(math.clamp(game.Workspace.Song.PlaybackLoudness, 100, 255)), 23, 225)
	end
end	

what do the two colour numbers represent, since theres usually 3 numbers. “100, 255”

The virst value is the playbackloudness, since it returns an integer.

and the other 3 is the colors?

1 Like

unknown global error to “children”

Where did you place the script?

starterpack like you told me to