How do I get the max volume of a sound

I’m trying to make a very simple if loop that runs every heartbeat in a simulation, so it loops very quickly.
The if loop checks if the volume is higher than the max volume, which starts at 0. If it is higher, then it updates the max volume to the volume. However, when I run it, it just prints the volume normally.

another way of saying it

problem is, the max volume goes up and down. Its supposed to only go up.

	local maxvol = 0
	local volume = sound.PlaybackLoudness
	if volume > maxvol then
		maxvol = volume
		print(maxvol)
	end

Where is the loop?

If you are setting maxvol back to 0 every time it will go ‘down’

oh uh yeah thats a good point mb :sweat_smile: