So, I need an audio setting or script that would decrease the volume of the audio the further you are away from it
Sadly I don't have any script except for
script.parent:play()
Okay...you have to use something called magnitude, which will check the points of the Player's Torso to a certain Part. In the case of what you're doing, here is what your script would look like (please note that this script is meant for a button that plays music or a sound) :
char = script.Parent.Parent.Character part = script.Parent.Parent audio = script.Parent bool = true function onTouch() if bool == false then return end -- Debounce ensures that this only occurs once bool = false if part:FindFirstChild("Humanoid") ~= nil then audio:Play() if char.Torso.magnitude > part.magnitude then for _,i in pairs(char.Torso.magnitude >= part.magnitude) do -- For every time the Player's Torso is far away... audio.Volume -= 0.1 -- Decrease the volume end end end wait(5) bool = true end part.Touched:connect(onTouch)
This is only my attempt to do what you're doing and I apologize if I am wrong. However, I believe that it is indeed necessary to use magnitude.
Usefull links:
EDIT:
If you take a look at the fist link, it talks exactly about what you are requesting help with: 3D sounds. For detailed information in regards of the properties of the Sound
instance, in order for you to build up your 3D sound, I left you the second link.
You can try adding "sound" to your workspace.
Then you can replace the idea and change the volume or whatever the property you change.
Then add a script (put inside of the sound) and type.
script.Parent:play()
if you don't want to add a script to the sound, try
game.workspace.sound:play()
either works fine.