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