Hello everyone, I’m a new member and this is my first post. (Maybe it would be helpful also to tell me if this post is good or how should I improve it. I’ll be making like 10 posts because I’ve wanted to join the DevForum forever)
-
What do you want to achieve? Keep it simple and clear!
I want to make a chat mute button for my admin panel. It will stop the player from sending any messages but they should still be able to see the chat. -
What is the issue? Include screenshots / videos if possible!
I literally have no idea how to.
The way my admin panel works is you can select a person from a character list.
Code:
local button = script.Parent
local selected = script.Parent.Parent.Parent.playerscroll.IsClicked
local selectedName = script.Parent.Parent.Parent.playerscroll.SelectedName
local TextChatService = game:GetService("TextChatService")
local isOn = false
local player = game.Players.LocalPlayer
local isMuted = false
local function muteUserId(mutedUserId)
-- listen for future TextSources
TextChatService.DescendantAdded:Connect(function(child)
if child:IsA("TextSource") then
if child.UserId == mutedUserId then
child.CanSend = false
end
end
end)
-- mute any current TextSources
for _, child in TextChatService:GetDescendants() do
if child:IsA("TextSource") then
if child.UserId == mutedUserId then
child.CanSend = false
end
end
end
end
-- Function to toggle chat mute
local function toggleChatMute()
if selected then
if selectedName ~= "" then
if isMuted then
isMuted = false
button.label.Text = "Mute"
else
muteUserId(game.Players.LocalPlayer.UserId)
isMuted = true
button.label.Text = "Unmute"
end
end
end
end
button.MouseButton1Click:Connect(toggleChatMute)
The selected and selected name variable are if a person has selected a player to take action against (ban, warn, mute, ect)
-
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I’ve tried but for some reason most of the solutions didn’t work. More specifically, I looked at the only 2 posts that really tell you about this. The first one I looked at used the old chat system but this is the one i looked at.