How to set a sound's volume / how to use SetVariableOnSound

Does anyone know how to properly use SetVariableOnSound ? I’m trying to set the volume/loudness of a sound I’m playing, but nothing seems to be working. I’ve done some research and it seems that the base game uses the "Loudness" parameter for the second argument when setting the volume, but nothing is happening. Any ideas?

local sid = GetSoundId()
PlaySoundFromCoord(sid, "scanner_alarm_os", pos.x, pos.y, pos.z + 0.5 , "dlc_xm_iaa_player_facility_sounds", 1, 100, 0)
SetVariableOnSound(sid, "Loudness", 0.1)