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

[RESOLVED] How to make ambient sounds zone based?

Asked by
tahu19 5
9 years ago

How can you script your game so that when ever you enter a different area/portion of the game, a different audio file plays ambiently and locally?

1 answer

Log in to vote
0
Answered by 9 years ago

There are 2 ways that you can go about doing this. 1. Region3 Use FindPartsInRegion3 to check if the player is in a region3, if so, play the local ambient sound. 2. Distance from a center Have a Vector3 value as a center of your "zone", if the player's torso is positioned within the radius of the zone, play the sound. To get the distance between 2 Vector3s, get the magnitude of the difference of the two Vector3s. e.g,

local Vec1 = Vector3.new(0,0,0)
local Vec2 = Vector3.new(0,5,0)
print((Vec1-Vec2).magnitude)

I personally prefer the second method. For no particular reason. You should read more about Region3 on the wiki to use the first method.

Ad

Answer this question