I Want to make it so the player is muted when the remote event is fired but it doesnt work and doesnt provide a error. robloxapp-20231218-2124365.wmv (661.7 KB)
events.Mute.OnServerEvent:Connect(function(plr,PlayerToMute)
if game.TextChatService.ChatVersion == Enum.ChatVersion.LegacyChatService then
local ChatService = require(game:GetService("ServerScriptService"):WaitForChild("ChatServiceRunner"):WaitForChild ("ChatService"))
local channel = ChatService:GetChannel("ALL")
channel:MuteSpeaker()
elseif game.TextChatService.ChatVersion == Enum.ChatVersion.TextChatService then
local TextChatService = game:GetService("TextChatService")
local function muteUserId(mutedUserId)
TextChatService.DescendantAdded:Connect(function(child)
if child:IsA("TextSource") then
if child.UserId == mutedUserId then
child.CanSend = false
end
end
end)
for _, child in TextChatService:GetDescendants() do
if child:IsA("TextSource") then
if child.UserId == mutedUserId then
child.CanSend = false
end
end
end
end
muteUserId(PlayerToMute.UserId)
end
end)
Summary
The mute system doesnt mute the player and doesnt give any sort of error not even a warning, the code was found on the devforum.
----- || SERVICES || -----
local ServerScriptService = game:GetService("ServerScriptService")
local TextChatService = game:GetService("TextChatService")
local Players = game:GetService("Players")
----- || VARIABLES || -----
local PlayerStorage = {}
local MuteSignal = events.Mute.OnServerEvent
local UnMuteSignal = events.Unmute.OnServerEvent
local ChatVersion = TextChatService.ChatVersion
local ChatService = ChatVersion == Enum.ChatVersion.LegacyChatService and require(game:GetService("ServerScriptService"):WaitForChild("ChatServiceRunner"):WaitForChild("ChatService")) or nil
----- || METHODS || -----
function MuteSpeaker( player : Player, target : Player )
PlayerStorage[target.UserId] = false
if ChatVersion == Enum.ChatVersion.TextChatService then return end
ChatService:GetChannel("ALL"):MuteSpeaker(player.Name)
end
function UnmuteSpeaker( player : Player, target : Player )
PlayerStorage[target.UserId] = false
if ChatVersion == Enum.ChatVersion.TextChatService then return end
ChatService:GetChannel("ALL"):UnmuteSpeaker(player.Name)
end
function PlayerAdded( player : Player )
if PlayerStorage[player.UserId] then return end
PlayerStorage[player.UserId] = true
end
function PlayerRemoving( player : Player )
PlayerStorage[player.UserId] = nil
end
----- || MAIN SCRIPT || -----
MuteSignal:Connect(MuteSpeaker)
UnMuteSignal:Connect(UnMuteSignal)
for _, player in Players:GetPlayers() do PlayerAdded(player) end
Players.PlayerAdded:Connect(PlayerAdded)
Players.PlayerRemoving:Connect(PlayerRemoving)
Background = coroutine.wrap(function()
while task.wait(1) do
if ChatVersion == Enum.ChatVersion.LegacyChatService then break end
for _, speaker in TextChatService:GetDescendants() do
if not speaker:IsA("TextSource") then continue end
speaker.CanSend = PlayerStorage[speaker.UserId]
end
end
end)()