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

I'm having issues with a radio script I made, can someone help?

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?

1 answer

✓ Accepted answer

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!):

Emitter Size Max Distance

Right now you should try this.

song.MaxDistance = 10
song.EmitterSize = 10

You can always adjust the sizes.

3 comments

0

@RjsMc is correct

0

@RjsMC Thanks, I tried this and it didn't work, but I checked out the emitter size page and realised it needed to be a child of a part for it to work. I was putting it in the character model, so I just had to make it a child of the head, so thanks!

0

Not even I knew that lol. The more we know xD

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