Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Can i have help with an audio volume decrease when your away from it?

Asked by 6 years ago
Edited 6 years ago

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()

3 answers

Log in to vote
0
Answered by 6 years ago

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.

0
Wait, i think i know what you meant, like a part script, yeah that works! ment34591 20 — 6y
Ad
Log in to vote
0
Answered by 6 years ago
Edited 6 years ago

Usefull links:

link1

link2

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.

0
Read my answer, please. That won't help. DeceptiveCaster 3761 — 6y
Log in to vote
0
Answered by 6 years ago

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.

0
I think this is what you looking for. NexoKami 12 — 6y
0
I know that, i want a script or audio setting that makes it so the audio volume decreases the farther your away from it ment34591 20 — 6y
0
Timmy, that won't work! It will only decrease it immediately to 0. DeceptiveCaster 3761 — 6y

Answer this question