How to mute a player using the new Roblox Audio Api feature?

Recently i discovered that roblox has new voice chat update.
So… I’d like to know how to mute a player via local script.
If anyone has any knowledge on this that would be appreciatable!
image (2)

maybe this will help you with your issue!

its a bit outdated.
After Sound Api update in player values i saw that you can mute player’s input device but it seem not to work properly for me so…
im trying to find people who found out how

In order to locally mute another player with the new Audio API, you’ll need to reference that player’s AudioDeviceInput and set its Muted property to true.

As an example:

  1. Create a ScreenGui and add a Frame into it.

  2. Add a TextBox, a TextButton, and a LocalScript into the frame.

    • The TextBox would be where you can type the name of another player in the game
    • Afterwards, the TextButton would be pressed when a player wants to locally mute / unmute that player.
  3. In the LocalScript, we need to do the following things:

    • Listen for the TextButton to be pressed with the Activated event.

    • Check if the Text that the player typed into the TextBox is the name of another player that is currently in the game.

    • If that player is in the game, check if there is an AudioDeviceInput that was created for that player (which will be added to the player object, by default, if the player has voice chat enabled and the VoiceChatService.EnableDefaultVoice property is enabled.

    • If an AudioDeviceInput was found, update its Muted property to the opposite value of what it currently is (so that if the player isn’t locally muted, it will mute them, but if they have already been muted, it will unmute them).

Here’s an example of what the code for the LocalScript might look like:

local Players = game:GetService("Players")

local Frame = script.Parent
local TextBox = Frame:WaitForChild("TextBox")
local TextButton = Frame:WaitForChild("TextButton")

    local Text = TextBox.Text
    if Text == nil then return end

    local lowercaseTextBoxText = string.lower(Text)

    local player
    for _, otherPlayer in Players:GetPlayers() do
        local lowercasePlayerName = string.lower(otherPlayer.Name)

        if lowercasePlayerName == lowercaseTextBoxText then
            player = otherPlayer

    if not player then return end

    local AudioDeviceInput = player:FindFirstChildOfClass("AudioDeviceInput")
    if not AudioDeviceInput then return end

    local currentValue = AudioDeviceInput.Muted
    AudioDeviceInput.Muted = not currentValue
1 Like

well ig i got it now, and script also works wonders!
Tysm, hope you have a good day!

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.