Don’t know if this is the right category to ask, but is it possible to add like a voice chat audio detector in a horror game? Like that one game “Don’t Scream”
You can detect audio using the AudioAnalyzer class
In the VoiceChatService
instance in your explorer, it has a property called UseAudioApi
, enable that
Every player gets an AudioDeviceInput
instance and every character a AudioEmitter
instance, so you can feed into an AudioAnalyzer
and read its .RmsLevel
to see how loud the input is
Example:
local Players = game:GetService("Players")
local RunService = game:GetService("RunService")
local THRESHOLD = 0.05 -- adjust to taste
Players.LocalPlayer.CharacterAdded:Connect(function(char)
-- wait for the audio‐input and emitter to show up
local micInput = Players.LocalPlayer:WaitForChild("AudioDeviceInput")
local analyzer = Instance.new("AudioAnalyzer")
analyzer.Parent = char
-- wire the mic → analyzer
local wire = Instance.new("Wire")
wire.SourceInstance = micInput
wire.TargetInstance = analyzer
wire.Parent = analyzer
-- monitor volume each frame
RunService.Heartbeat:Connect(function()
if analyzer.RmsLevel >= THRESHOLD then
-- player is “screaming” loud enough!
print("VOICE DETECTED at level", analyzer.RmsLevel)
-- do stuff here
end
end)
end)
1 Like