So I have a local script that creates an AudioDeviceInput to the player’s mic and then connect it to a audio analyzer on the character but for some reason the audio analyzer’s RmsLevel dosen’t change
here is the code
local players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local plr = players.LocalPlayer
local JumpActivated = ReplicatedStorage:WaitForChild("RemoteEvents"):WaitForChild("Talk")
local input = Instance.new("AudioDeviceInput", plr)
input.Name = "MicrophoneInput"
input.Player = plr
local function connect(src: Instance, dst: Instance)
local wire = Instance.new("Wire", dst)
wire.SourceInstance = src
wire.TargetInstance = dst
end
local function OnCharacterSpawned(player: Player, character: Model)
local analyzer = Instance.new("AudioAnalyzer", character)
connect(input, analyzer)
local debounce = false
local running = true
local function onAncestryChanged(_, parent)
if not parent then
running = false
end
end
character.AncestryChanged:Connect(onAncestryChanged)
coroutine.wrap(function()
while running do
if not debounce and analyzer.RmsLevel > 0.015 then
debounce = true
JumpActivated:FireServer()
task.delay(0.1, function()
debounce = false
end)
end
task.wait(0.1)
end
end)()
end
local function onCharacterAdded(character)
OnCharacterSpawned(plr, character)
end
if plr.Character then
onCharacterAdded(plr.Character)
end
plr.CharacterAdded:Connect(onCharacterAdded)