So I was just working with ROBLOX’s new Audio API that’s been released. I saw in Roblox documents, they had created a push-to-talk script, just what I needed.
I’ve also created an AudioDeviceInput and put it in the VoiceChatService along with my local script.
For some reason, this doesn’t work at all. I’m not getting any error or warning, nor is this working in game. I have enabled microphone to talk in game settings, but I’m unable to get this to work. Please help!
local players = game:GetService("Players")
local userInput = game:GetService("UserInputService")
local audioIn : AudioDeviceInput = players.LocalPlayer:WaitForChild("AudioDeviceInput")
audioIn.Muted = true
local pushToTalkKey = Enum.KeyCode.V
userInput.InputBegan:Connect(function(input: InputObject)
if input.KeyCode == pushToTalkKey then
audioIn.Muted = false
end
end)
userInput.InputEnded:Connect(function(input: InputObject)
if input.KeyCode == pushToTalkKey then
audioIn.Muted = true
end
end)