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.
Script that I made using a radio script I found on a game.
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
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!
--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