Code isn't running while not throwing errors

  1. What do you want to achieve?
    I am trying to detect when a player is talking in VC through an Audio Device Input

  2. What is the issue?
    For some reason, when the code runs, it doesn’t create the new instance, or the wire, and it doesn’t parent it to the player. Im running it through a Server Script, and I have checked on both the client and the server, as well as running the same script through command line, yet it still does not work, and does not throw errors.

for _, plr in game:GetService('Players'):GetPlayers() do
	if plr:FindFirstChild('AudioDeviceInput') then
		local audiodeviceinput = plr.AudioDeviceInput
		local Analyzer = Instance.new("AudioAnalyzer")
		Analyzer.Name = plr.Name
		Analyzer.Parent = game.ReplicatedStorage.Shared.Analyzers
		local Wire = Instance.new("Wire")
		Wire.Parent = Analyzer
		Wire.SourceInstance = audiodeviceinput
		Wire.TargetInstance = Analyzer
	end
end

Any help would be amazing

  1. check players exist in the game when the code runs
  2. add prints; if you print an instance and click on it then you can automatically go to it in the explorer and if it doesnt go anywhere then the instance parent is nil
print("running")
for _, plr in game:GetService('Players'):GetPlayers() do
    print("player", plr)
	if plr:FindFirstChild('AudioDeviceInput') then
        print("passed")
		local audiodeviceinput = plr.AudioDeviceInput
		local Analyzer = Instance.new("AudioAnalyzer")
		Analyzer.Name = plr.Name
		Analyzer.Parent = game.ReplicatedStorage.Shared.Analyzers
		local Wire = Instance.new("Wire")
		Wire.Parent = Analyzer
		Wire.SourceInstance = audiodeviceinput
		Wire.TargetInstance = Analyzer
        print(Analyzer, Wire)
	end
end
1 Like

Thanks for your help, but I’ve fixed the issues!!

It was something to do with an interfering script.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.