Roblox provided voice chat script issue

I was experimenting with voice chat and the ability to show when a player has voice chat to non vc able players (I hope you followed that) and when messing with the Roblox provided voice chat detection script.


local Players = game:GetService("Players")
local VoiceChatService = game:GetService("VoiceChatService")

local localPlayer = Players.LocalPlayer
local success, enabled = pcall(function()
    return VoiceChatService:IsVoiceEnabledForUserIdAsync(localPlayer.UserId)
end)
if success and enabled then
    print("success ez")
    localPlayer.PlayerGui.MyVoiceGui.Enabled = true
end

I get no return through output and nothing saying it’s working. It’s in a local script as of right now.
If anyone could help me it would mean a great bit. Thanks!

If you don’t have voicechat enabled on your account then it won’t print anything because you didn’t set it up to.

1 Like

I do have it enabled. I’m still getting no return

Oh okay, thanks for the clarification.

Try adding a print statement inside this pcall to see if it actually runs.

I’ll check it out thanks. I’m at school right now so I’ll get back to you about that in a few hours.

Also is spatial voice chat enabled on your game in the settings of it?
Turn it on and the original script should work.

Yes it is, tested it with a friend just to be double sure.

Try this,

local Players = game:GetService("Players")
local VoiceChatService = game:GetService("VoiceChatService")
local localPlayer = Players.LocalPlayer

local success, enabled = pcall(function()
	return VoiceChatService:IsVoiceEnabledForUserIdAsync(localPlayer.UserId)
end)

if enabled then
	print("success ez")
	localPlayer.PlayerGui.MyVoiceGui.Enabled = true
end
2 Likes

Thanks for all that helped, I found the issue. Im just an idiot lol

had the script running in the workspace when it should have been in the starter player scripts all along. Sorry!