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!
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:
-
Add a
TextBox
, aTextButton
, and aLocalScript
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.
- The
-
In the
LocalScript
, we need to do the following things:-
Listen for the
TextButton
to be pressed with theActivated
event. -
Check if the
Text
that the player typed into theTextBox
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 theVoiceChatService.EnableDefaultVoice
property is enabled. -
If an
AudioDeviceInput
was found, update itsMuted
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")
TextButton.Activated:Connect(function()
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
break
end
end
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
end)
well ig i got it now, and script also works wonders!
Tysm, hope you have a good day!
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.