Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How do I control audio range?

I have a Part which has a Sound item in it, as well as a Script that runs the Sound item. I have a movie theater that plays videos on the screen and 4 speakers per auditorium. I'd like to know how I can prevent all the audio in the game from overlapping each other.

So is there a way to set the range of audio (Kind of like setting the range of a light)?

2 comments

1

Are they playing at the same time? If they are, you have to script it so that its for the local player in every auditorium. You dont want multiple sounds to be playing in the workspace.

0

@TrollD3 That would fix the overlapping audios.

2 answers

✓ Accepted answer

Since this is not a request site I will just tell you how to do it, but not give you the script. The way I know would work is if you have a script in the speaker that checks if players are within the max distance to be able to hear it using magnitude. If the player is within the distance it should check if the player already has the sound in his PlayerGui, if not then it should create the sound and play it at the same time position as the main sound (you will have to set the volume to 0, put it in workspace and play it). If you attempt to do this and it doesn't work, create another post but with your attempt and I will help you out. Please vote up and accept as answer if this helps!

1 comment

0

Thanks, I'll accept this as an answer and provide the script I made using it in a different answer.

This is the final result that works for me!

wait(3) --Wait for the game to load, increase on slower computers (or find other fix)
local player = script.Parent.Parent.Parent.Character.Torso
screen = game.Workspace.Screen2
while true do
	if (screen.Position - player.Position).magnitude > 105 then --105 bricks away
		script.Parent.Audio2.P1.Volume = 0 --Mute
		script.Parent.Audio2.P2.Volume = 0
	else
		script.Parent.Audio2.P1.Volume = 0.25 --Otherwise volume 25%
		script.Parent.Audio2.P2.Volume = 0.25
	end
	wait()
end

1 comment

0

That's great! Good job, I'm glad it worked for you.

This discussion is preserved as it was. New answers, comments, and votes are closed.