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

Audio Pitch Distance?

Asked by
j1011 0
9 years ago

How do i adjust the audio or sound that is running on my game when you are far away from the object that has the sound?

1
Roblox, automatically does this with distance, however changing pitch would simply get the magnitude to the two positions and change the pitch arcoding to the distance RM0d 305 — 9y

1 answer

Log in to vote
0
Answered by 9 years ago

Even if ROBLOX automatically does the Distance thing if a sound is inside a 3D Object like a part. If one person is close to it and one person is far away, it would sound the same. We can use a LocalPart for that.


To make the local part use a local script. Make the Part Parent = workspace.Camera

Instance.new("Part",workspace.Camera)

Finished Script

This uses get distance from character.

(Local Script!)

local part = Instance.new("Part",workspace.Camera)
--Change everything like size and position.
local sound = Instance.new("Sound", part)
--Change the SoundId and everything.
local plyr = game:GetService("Players").LocalPlayer

while wait() do --There is a better way to do this, I just need to write this quickly...
    if plyr:GetDistanceFromCharacter(part.Position) < 15 then
        sound.Pitch = .5 --This is an example. You may edit this script.
    end
end


Hope this helps!(You need to edit the above script. It's just an example.)

Ad

Answer this question