Help with detecting how loud a users mic is

Hello so bassically I have a horror game and I want to implement servers with the voice chat so that if they are speaking above a threashold then the monster is alerted to their position.

There are a few things I wanted to ask about

  1. is player.AudioRecording.MicrophoneSamplePeak a real thing?

  2. Can I do if userInputService:IsKeyDown(Enum.KeyCode.LeftControl) then to detect if they are using their mic?

I would get these answers myself however I do not have voice chat.

Here is a code I mode which I think would work but I can’t test.

local player = game:GetService("Players").LocalPlayer
local userInputService = game:GetService("UserInputService")

local micVolumeThreshold = 0.5

while true do
    if userInputService:IsKeyDown(Enum.KeyCode.LeftControl) then
        local micLevel = player.AudioRecording.MicrophoneSamplePeak
        if micLevel > micVolumeThreshold then
            -- Alert the monster to the player's position
            print("Player's mic volume is too loud!")
        end
    end
    
    wait(0.1)
end

1 Like

that is the coolest thing ive seen, but I don’t think that audio recording is a real thing yet, maybe it’ll come in the new dynamic face update.