Kick players who has voice chat disabled

The script works except for line 5 (print("Voice Chat Is Disabled For “…player.Name”)
How do I fix this?

Script:

local VCS = game:GetService("VoiceChatService")

local player = game.Players.LocalPlayer

if VCS:IsVoiceEnabledForUserIdAsync(player.UserId) == true then print("Voice Chat Is Enabled For "..player.Name)

else

print("Voice Chat Is Disabled For "..player.Name)

player:kick("To play this game you must have voice chat enabled!")

end
2 Likes

Try print("Voice chat is disabled for", player.Name)

1 Like

Nope, still doesn’t work. Any other suggestions?

Is there an error that returns?

Nope. It does kick the player who doesn’t have voice chat enabled but does not print anything

I don’t really know what to suggest, it runs the line after the print() but not the print itself?

The other print line works on line 3 then print("Voice Chat Is Enabled For "…player.Name)

But not the print line for when a player doesn’t have voice chat enabled

maybe try binding it to playeradded event?

I’m not sure what that is. I don’t know how to script other then going on the roblox dev site and getting the script and fixing it to how I want it to work.

I got the issue, he is probably testing with 2 players and the script is probably a LocalScript, that causes him to see nothing on his output

tell the user to press F9 (Keybind to open Developer Console) and send a screenshot of it, you will see that it prints something on their side.

The player that has voice chat disabled gets kicked which that part of the script works

are you testing it all yourself or with another user?

I join on my main (voicechat enabled) and then on a alt account which voicechat is disabled on.

ok, when you join the game on your alt account and get kicked. Press F9 when you are kicked, you will see that it prints what you wanted

It instantly kicks the alt so I wouldn’t be able to open console

find a way to open the Dev console then, or simply remove the kick function.

I removed the kick line to test and see if it prints on the alt. It does print in console on the alts side but when I go to my main account side I cannot see it

I think IsVoiceEnabledForUserIdAsync is down for some reason?

Oh yea and this should kick the player if they join.

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

local function PlayerAdded(Player)
	local success, enabled = pcall(function()
		return VoiceChatService:IsVoiceEnabledForUserIdAsync(Player.UserId)
	end)
	
	if success and (not enabled) then
		Player:Kick("Voice chat is not enabled")
	else
		print("Api down?")
	end
end

Players.PlayerAdded:Connect(PlayerAdded)

for _, Player: Player in pairs(Players:GetPlayers()) do
	task.spawn(PlayerAdded, Player)
end

thats because its a LocalScript, they only function on your side. your main account has Voicechat enabled so it doesn’t prints the thing you wanted but on the alt account it has Voicechat disabled so it runs the print function for the alt account.

if you liked the solution make sure to mark it as a solution.

2 Likes