Help with Mute command

Hello everyone! I am trying to make a mute command for my game and the code does not seem to work as it should, when i added the mute command, my other commands stopped working. Any help would be appriciated!

game.Players.PlayerAdded:Connect(function(player)
	local DataStoreService = game:GetService("DataStoreService")
	local BanStore = DataStoreService:GetDataStore("Save","Ban")
	local ChatService = require(game:GetService("ServerScriptService"):WaitForChild("ChatServiceRunner"):WaitForChild ("ChatService"))
	local Channel = ChatService:GetChannel("All")

	local success, errorMessage = pcall(function()
		local ban = BanStore:GetAsync(player.UserId)
		if ban.Banned == true then
			player:Kick("Banned, reason: "..ban.BanReason)
		end
	end)
	if success then
		print("Successful load")
	else
		warn(errorMessage)
	end
	
	if player.UserId ~= 3352681354 then return end
	
	player.Chatted:connect(function(message)
		local words = string.split(message," ")
		
		local prefix = ":"

		if string.find(words[1],prefix) ~= 1 then return end
		words[1] = string.split(words[1],prefix)[2]
		

		if words[1] == "mute" then
			local target
			for _,p in pairs(game.Players:GetPlayers()) do
				local playerName = string.lower(p.Name)
				if string.match(playerName,string.lower(words[2])) then
					target = p
					break
				end
			end
			if target then
				Channel:MuteSpeaker(target)
			end
			
			if words[1] == "kill" then
				local target
				for _,p in pairs(game.Players:GetPlayers()) do
					local playerName = string.lower(p.Name)
					if string.match(playerName,string.lower(words[2])) then
						target = p
						break
					end
				end
				if target.Character then
					target.Character.Humanoid.Health = 0
				end
			
		elseif words[1] == "kick" then
			local target
			for _,p in pairs(game.Players:GetPlayers()) do
				local playerName = string.lower(p.Name)
				if string.match(playerName,string.lower(words[2])) then
					target = p
					break
				end
			end
			local reason = words
			for rep = 1, 2 do
				table.remove(reason,1)
			end
			reason = table.concat(reason," ")
			if target then target:Kick(reason) end
			
			if player:GetRankInGroup(14196783) >= 248 then return end
			
		elseif words[1] == "ban" then
			local target
			for _,p in pairs(game.Players:GetPlayers()) do
				local playerName = string.lower(p.Name)
				if string.match(playerName,string.lower(words[2])) then
					target = p
					if target == player then
						return
					end
					break
				end
			end
			
			local targetId

			if not target then
				local _,e = pcall(function()
					targetId = game.Players:GetUserIdFromNameAsync(words[2])
				end)

				local _,e2 = pcall(function()
					game.Players:GetNameFromUserIdAsync(tonumber(words[2]))
				end)
				if e and e2 then
					return
				end
				if not e2 and e then
... (62 lines left)
1 Like

Are any errors printing in the Output?

1 Like

1 Like

Try changing line 169 to return self.Speakers[speakerName.Name:lower()].

That is the script roblox generated for us in the game. We can’t change it. (Writing for a friend who doesn’t have acess to devforum)

1 Like

You should be able to if you join a game in studio, copy the Chat folder under Chat and then exit playtest and paste it into Chat in studio.

Which Chatfolder? Should we copy all?

Yes, all of them. charsssssssss

It just duplicates the chat when we do it.

1 Like

Only copy the folders and scripts inside the Chat Folder. Then close the Testing game thing in studio then paste into the chat folder.

And don’t just copy the chat it self