How do I create a global server voice chat?

  1. I want people with voice chat to have no “spatial” audio. I want all players to hear each other within a server using the new audio API - utilizing wires.

  2. Script that I made using a radio script I found on a game.

  3. I’ve Looked through the devforum for resources, but I’m still confused about how these things work.

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
1 Like

Try this:

local players = game:GetService("Players")

-- Create a global listener for all audio
local globalListener = Instance.new("AudioListener", game.Workspace)
globalListener.Name = "GlobalAudioListener"

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 each player's input to the global listener
	connect(input, globalListener)
end

players.PlayerAdded:Connect(onPlayerAdded)
for _, player in players:GetPlayers() do
	onPlayerAdded(player)
end

This should work, Let me know if you have any further questions!

1 Like

Did you ever get this working? I am playing around and theres a lot of confusion with all the dozen new instances added with this update.

1 Like

20 months later here’s the solution :star:

--Script in ServerScriptService
local Players = game:GetService("Players")

local function connect(src: Instance, dst: Instance)
	local wire = Instance.new("Wire")
	wire.SourceInstance = src
	wire.TargetInstance = dst
	wire.Parent = dst
end

local function onPlayerAdded(player: Player)
	player.CharacterAdded:Wait()

	-- Create Audio Devices
	local input = Instance.new("AudioDeviceInput")
	input.Name = "VoiceInput"
	input.Player = player
	input.Parent = player

	local output = Instance.new("AudioDeviceOutput")
	output.Name = "VoiceOutput"
	output.Player = player
	output.Parent = player

	for _, other in Players:GetPlayers() do
		if other ~= player then
			local otherOutput = other:FindFirstChild("VoiceOutput")
			if otherOutput then
				connect(input, otherOutput)
			end
		end
	end

	for _, other in Players:GetPlayers() do
		if other ~= player then
			local otherInput = other:FindFirstChild("VoiceInput")
			if otherInput then
				connect(otherInput, output)
			end
		end
	end
end

Players.PlayerAdded:Connect(onPlayerAdded)

for _, player in Players:GetPlayers() do
	task.spawn(onPlayerAdded, player)
end

I can’t find a way to disable the icon above the player’s head tho