VoiceChatService
VoiceChatService is responsible for voice chat's high-level functionality. This mostly consists of configuration options, and functions that are not specifically-controlled by more-specific instances.
概要
プロパティ
Controls whether each voice-eligible player can be heard as though they were speaking through their character.
Controls whether voice chat is represented and controlled by AudioDeviceInput objects.
方法
Returns whether or not the given user has voice enabled.
プロパティ
EnableDefaultVoice
When enabled, each voice-eligible player can be heard as though they were speaking through their character. The implementation details of the voice setup depend on UseAudioApi.
When UseAudioApi is Disabled, disabling the default voice setup effectively disables voice chat altogether.
UseAudioApi
If Enabled, the voice chat setup is represented and controlled by AudioDeviceInput objects. More specifically:
- An AudioDeviceInput will be created and parented to each voice-eligible Player.
- An AudioEmitter will be created and parented to each voice-eligible player's Player.Character.
- An AudioListener will be created and parented to Workspace.CurrentCamera.
If Disabled, the voice chat setup is done through an internal-only system.
Currently, setting this to Automatic has the same meaning as Disabled. However, in the future, Automatic will become Enabled, so that new experiences can achieve greater customization over voice.
方法
IsVoiceEnabledForUserIdAsync
Returns whether or not the given user has voice enabled. On the client-side, this can only be used to check the voice status of the local player. On the server-side, this can only check the voice status for players in that server.
This function can throw an error if the HTTP call fails.
local Players = game:GetService("Players")
local VoiceChatService = game:GetService("VoiceChatService")
local localPlayer = Players.LocalPlayer
local success, enabled = pcall(function()
return VoiceChatService:IsVoiceEnabledForUserIdAsync(localPlayer.UserId)
end)
if success and enabled then
print("Voice chat enabled!")
end
パラメータ
The Player.UserId to check.
戻り値
If that user has voice enabled.