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

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

Asked by 6 years ago

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

Log in to vote
1
Answered by
RjsMc 48
6 years ago

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.

0
@RjsMc is correct Chez_Guy 67 — 6y
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! baggyman674 2 — 6y
0
Not even I knew that lol. The more we know xD RjsMc 48 — 6y
Ad

Answer this question