Create a global voice chat (no spatial) using the new audio API, utilizing a wire + input/output
I cannot hear other people’s voice chat audio. My guess is the input is being replayed to the output. Which isn’t the same output as X player. I’m not sure.
I’ve tried using the new audio documentation and changing the “Radio” script found in the development game. I can’t figure out how to set this up correctly (I made a few adjustments to a radio script).
After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
local players = game:GetService("Players")
local function connect(src: Instance, dst: Instance)
local wire = Instance.new("Wire", dst)
wire.SourceInstance = src
wire.TargetInstance = dst
end
local function onPlayerAdded(player: Player)
local input = Instance.new("AudioDeviceInput", player)
input.Player = player
local output = Instance.new("AudioDeviceOutput", player)
output.Player = player
connect(input, output)
end
players.PlayerAdded:Connect(onPlayerAdded)
for _, player in players:GetPlayers() do
onPlayerAdded(player)
end
Hey @Distantlyz – assuming you’ve got VoiceChatService.UseAudioApi set to Enabled, this script is super close, I think there’s just one line preventing this from working as intended
In this section,
local input = Instance.new("AudioDeviceInput", player)
input.Player = player -- sets which player provides the input
local output = Instance.new("AudioDeviceOutput", player)
output.Player = player -- sets which player receives the output
assigning output.Playerrestricts who can hear it! So this script creates an AudioDeviceInput and AudioDeviceOutput for each player when they join, but each player can only hear themselves.
It would probably work just by removing this line:
output.Player = player
But better yet, instead of creating an AudioDeviceOutput per-person, you could create one shared AudioDeviceOutput that everyone can hear, and everyone’s AudioDeviceInput connects to; e.x.
local output = Instance.new("AudioDeviceOutput")
output.Parent = workspace -- this can really go anywhere
local players = game:GetService("Players")
local function connect(src: Instance, dst: Instance)
local wire = Instance.new("Wire", dst)
wire.SourceInstance = src
wire.TargetInstance = dst
end
local function onPlayerAdded(player: Player)
local input = Instance.new("AudioDeviceInput", player)
input.Player = player
connect(input, output)
end
players.PlayerAdded:Connect(onPlayerAdded)
for _, player in players:GetPlayers() do
onPlayerAdded(player)
end
Also, you may want to add a local script that does something like
local me = game:GetService("Players").LocalPlayer
local myInput = me:FindFirstChildWhichIsA("AudioDeviceInput")
myInput.Volume = 0
-- and/or:
for _, wire in myInput:GetConnectedWires("Output") do
wire:Destroy()
end
so that you don’t hear yourself in the global chat