Invalid argument #3 to 'clamp' (max must be greater than or equal to min) when using playbackloudness for color3rgb

Hi there, I have a club floor I want to change color using playback loudness, however the values I put in lead to an error (I don’t understand what it is). I don’t know how to explain more in depth since I’m new to lua.

Console error

Players.vxsqi.PlayerGui.LocalScript:4: invalid argument #3 to 'clamp' (max must be greater than or equal to min) 

Script

local part = workspace.parts["Club Floor"]
local sound = workspace.Sound
while wait(0.01) do
	part.Color = Color3.fromRGB(math.floor(math.clamp(sound.PlaybackLoudness, 27, 9)), 137, 207)
end	

you are using math.clamp() wrong

math.clamp(Value, Min, Max)

obviously 9 isn’t the max value there, 27 is

3 Likes

I still don’t understand, also the last 3 numbers are the colors i want to transition through

think about it

why would it not error if you made the min higher then the max, just saying you are using math.clamp wrong

nope, i can’t get my head around it. I’ve tried searching up how math.clamp works but it’s too confusing

please help, this script was a script i followed of a tutorial but it didn’t explain some parts ):

wait, I did this and the floor does change colour, however it stays like that

part.Color = Color3.fromRGB(math.floor(math.clamp(sound.PlaybackLoudness, 9, 27)), 137, 207)

looking at this code it seems like you are only changing R(red)
also PlaybackLoudness goes up to 1000 so if it is higher then the “27” that you entered, it will stay at 27

so you could mess with the max number to see what works best

which part would be where im changing only red?

found it,
its flashing red now to the music

also, my main colour to go for is blue

well Color3.fromRGB(red, green, blue) takes red green and blue

I meant that red can only change every loop because of the playback loudness

thus that being 9? sorry if im acting stupid in any way

this is the colour im aiming for

9, 137, 207

do you only want to change red? depending on the sound?

depending on the sound yes, however not just red. This is the default brick color, “4, 175, 236”. I want that color to change through this color, “9, 137, 207” depending on the sound.

also, i had another topic ask about this however the person who helped me, only managed to get it to transition through red and not blue

how do you want to get to this color?
sorry if I am confused a bit


in the video above, you can see that it transitions through red and not the colour i desire which is 9, 137, 207

oh thanks I get it now

could you send me your current code?