Silencing (muting) an player

--//Services
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local StarterGui = game:GetService("StarterGui")

--//Variables
local SilenceManager = ReplicatedStorage.SilenceManager
local RequestSilence = SilenceManager:WaitForChild("RequestSilence")
local SilencePlayer = SilenceManager:WaitForChild("SilencePlayer")
local NotifyPlayer = SilenceManager:WaitForChild("NotifyPlayer")
local mutedPlayers = {}

--//Controls
local Group = 13791384
local AllowedRank = 15

--//Functions
RequestSilence.OnServerEvent:Connect(function(player, playerNameToSilence, reason)
	if reason and type(reason) ~= "string" then
		return
	end

	if not playerNameToSilence or type(playerNameToSilence) ~= "string" or player:GetRankInGroup(Group) < AllowedRank then
		return
	end

	local playerToSilence = Players:FindFirstChild(playerNameToSilence)

	if not playerToSilence then
		return
	end

if mutedPlayers[playerToSilence] then return end
mutedPlayers[playerToSilence] = true

	SilencePlayer:FireClient(playerToSilence, reason)
	NotifyPlayer:FireClient(player, "Panel", "The player has been successfully silenced.")
end)
1 Like

It worked thank you so much. :smile:

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