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
-
is player.AudioRecording.MicrophoneSamplePeak a real thing?
-
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