How would I make a mute command | feedbacks?

Hello, how would I make a mute command that if a admin run !mute (user) (time) (reason) it’s would mute them for the specified time and reason. I would need feedbacks on it. I am not asking for free scripts once again: I just wanna get somes feedbacks. Include an example please!

4 Likes

You need to disable their chat button using SetCoreGuiEnabled.

Example, a remote event mutes the player:

chatEvent.OnClientEvent:Connect(function()
	game:GetService("StarterGui"):SetCoreGuiEnabled(Enum.CoreGuiType.Chat, false)
end)

I wanna make it tho so if they try to chat I simply remove there message and would say “You are muted for (reason), (time) left before an unmute.”. Any feedbacks?

1 Like

make a gui visible that says ‘you’ve been muted for [‘reason’], you have [formatted time variable here’ before an unmute’ when they have been muted.

then when they try to chat show up the same popup.

but to remove their message idk how to do that

If you want to prevent their message from being shown, you need to fork the chat. It’s pretty difficult, so disabling their chat is the easier option but you can learn about forking the Lua Chat here: In-Experience Text Chat | Roblox Creator Documentation

Fun fact, you don’t have to fork the chat modules!!

You can easily mute/unmute a player through the built in Roblox chat using the following:

local chatService = require(game:GetService("ServerScriptService"):WaitForChild("ChatServiceRunner"):WaitForChild("ChatService"))

--Mute command code
chatService:GetChannel("All"):MuteSpeaker("MrLonely1221", "being rude to other players!", 60) --speakerName, reason, duration
--Unmute
chatService:GetChannel("All"):UnmuteSpeaker("MrLonely1221")
4 Likes

lets say if u mute someone for 1hr then that would be 3600 sec but when the player leaves the game and rejoins are they still muted?

You’d have to utilize DataStoreService for this.

1 Like

Can the player bypass this by changing their name

It’s common practice to save userdata through userid rather than a user’s name, so presuming you’re using a key that involves a player’s userid then no, they can’t bypass it.

1 Like

Can they bypass this line of code?

chatService:GetChannel(“All”):MuteSpeaker(“MrLonely1221”, “being rude to other players!”, 60)

Because the player name is there not the userid

1 Like

You can use the Players service and call the GetNameFromUserIdAsync() function after saving their userid in the datastore.

Then when they join, check if they’re muted and mute them again, or don’t if they aren’t. Then you don’t have to worry about username changes as you’re only seeing the user id and basing it off that and pulling the current name.