How do MaxDistance and EmitterSize work for sounds? I've been trying to figure this out for a while for my radio script I'm working on but I can't figure out what to set the values for these as so they don't play throughout the entire server and instead just a small area. The script:
local player = game.Players.LocalPlayer repeat wait() until player.Character~= nil local frame = script.Parent local play = frame.Play local speaker = frame.Speaker local input = frame.InputBox local song = Instance.new('Sound',frame) local playtoggle = true local speakertoggle = true local char = player.Character song.Looped = true song.PlayOnRemove = false song.Volume = 3 play.MouseButton1Click:connect(function() if playtoggle == true then print('playing') song.SoundId = 'rbxassetid://' .. input.text song:Play() play.Text = 'Stop' playtoggle = false print(playtoggle) wait(0.5) elseif playtoggle == false then print('stopping') song:Stop() play.Text = 'Play' playtoggle = true print(playtoggle) wait(0.5) end end) speaker.MouseButton1Click:connect(function() if speakertoggle == true then song.Parent = char speaker.BackgroundColor3 = Color3.new(0,255,0) speakertoggle = false print('speakeron') wait(0.5) song.EmitterSize = 1 print('Emittersize is ' .. song.EmitterSize) song.MaxDistance = 10 print('MaxDistance is ' .. song.MaxDistance) elseif speakertoggle == false then song.Parent = frame speaker.BackgroundColor3 = Color3.new(255,0,0) speakertoggle = true print('speakeroff') wait(0.5) end end)
I've tested this code on a server running on two separate computers to test the range of the sound a few times and I think there may be something wrong with it as I can still hear the song from the other side of the map even when it seems to fade, can someone point out what's wrong with it if so?
Based on what I know... EmitterSize
is just how much the audio will blast (AKA Sound radius). MaxDistance
is just the max radius of the sound.
I will add a code that could help. Right now you can read here (Very short!):
Right now you should try this.
song.MaxDistance = 10 song.EmitterSize = 10
You can always adjust the sizes.