local vc = game:GetService("VoiceChatService")
local success, enabled = pcall(function()
return vc:IsVoiceEnabledForUserIdAsync(game.Players.LocalPlayer.UserId)
end)
if success and enabled then
print(1)
end
But in Server this is not working:
local vc = game:GetService("VoiceChatService")
game.Players.PlayerAdded:Connect(function(player)
local success, enabled = pcall(function()
return vc:IsVoiceEnabledForUserIdAsync(player.UserId)
end)
if success and enabled then
print(1)
end
end)
Is there a way i can use this method or similar in the Server?
Thanks, i wanted to check if Voice Chat is enabled, if its enabled all the Players could see with a TextLabel that the Voice Chat is enabled, but there is now no secure, because Players can just say that their Voide Chat is enabled, its not that bad but why is Roblox dont making this Server-Sided?
Yeah this should be enabled on server side because using remotes by telling the server is unsecure when exploiters get hold of it and then can join into voice chat only servers or have any voice chat perks.
The IsVoiceEnabledForUserIdAsync method of VoiceChatService is a client-side method and cannot be called on the server directly.
If you want to check whether a player has voice chat enabled on the server, you can store the value of IsVoiceEnabledForUserIdAsync on the client in a DataStore or other persistent storage, and then retrieve that value on the server.
Here’s an example of how you could do this:
On the client:
local vc = game:GetService("VoiceChatService")
local ds = game:GetService("DataStoreService"):GetDataStore("VoiceChatEnabled")
-- Store the value of IsVoiceEnabledForUserIdAsync in the DataStore
local success, enabled = pcall(function()
return vc:IsVoiceEnabledForUserIdAsync(game.Players.LocalPlayer.UserId)
end)
if success then
ds:SetAsync(game.Players.LocalPlayer.UserId, enabled)
end
On the server:
local vc = game:GetService("VoiceChatService")
local ds = game:GetService("DataStoreService"):GetDataStore("VoiceChatEnabled")
game.Players.PlayerAdded:Connect(function(player)
-- Retrieve the value of IsVoiceEnabledForUserIdAsync from the DataStore
local success, enabled = pcall(function()
return ds:GetAsync(player.UserId)
end)
if success and enabled then
print("Voice chat enabled for player:", player.Name)
end
end)
This code will check the VoiceChatEnabled DataStore for each player when they join, and print a message to the server console if voice chat is enabled for that player. Note that the IsVoiceEnabledForUserIdAsync method may take a few seconds to return, so there may be a delay before the value is stored in the DataStore and can be retrieved on the server.
Datastore will never be allowed on client side, If it was allowed then exploiters would wipe all your game’s data in one simple click, And do not reply to posts with your code when you know nothing about coding, learn before postin invalid answers. Anyways you should already know it’s not possible.
Datastores should never be used on client and it won’t even run and just error.
And for this Voice chat thing just make a secure remote that can be used once to fire the value to the server right when the client starts.