VoiceChatSDK | Easily Mute & Unmute Players

image
Basically this but uses the new audio APIs.

VoiceChatSDK is a small module made to originally moderate misbehaving players, while also knowing if they get suspended from the Voice Chat to just simply knowing whether they can Voice Chat to begin with.

The module can be used both on the Server and Client, and is fully compatible with --!strict.

Functions that are included
MutePlayer ( Player, Seconds? ) -- Mutes the player for the duration of Seconds (or indefinitely).
UnmutePlayer ( Player ) -- Unmutes the player if they are muted. (No, this doesn't activate their microphone, creep.)
GetDeviceInput ( Player ) -- Returns the player's AudioDeviceInput instance, if one exists.
PlayerHasVoice ( Player ) -- Returns `true` or `false` depending on whether the player has Voice Chat or not.

-- There is also an event for when a player with Voice Chat gets suspended;
VoiceStripped -- Connections fire when a player gets their Voice Chat suspended while they are in-game.

The whole module is pretty primitive but it gets the job done for those who need it.

You can get the module here, or check the source in GitHub.

5 Likes

Infinite yield possible on ‘Player.[PlayerName]:WaitForChild(“AudioDeviceInput”)’

I also see on the documentation of VoiceChatService that UseAudioApi has to be enabled.

Any idea on how to enable this? I am new to using the Voice Chat API

Sincerest Apologies

Edit Update for anyone wondering/facing the same issue

“Model” tab in Studio
“Service” near the far right side
Click on “VoiceChatService” and then “Insert”
Scroll down in Explorer until you find “VoiceChatService”
In Properties find “UseAudioAPI” and set to “Enabled”

You can safely ignore this warning, all instances of the yield are wrapped in task.spawn() so they are not really causing any threading issues.

As for the UseAudioApi, it doesn’t matter as much either since they’re already out of beta. You just need to have Voice Chat enabled in the game.

The SDK will be compatible if you see this in your game info bar.
image

I recall getting this error before despite having UseAudioAPI enabled.

It happens when you try getting a players’ AudioDeviceInput without them having Voice Chat enabled.

That, or it takes too long for a player to load.