I know how to hide chat messages from the chat window, But i don’t know how to hide/delete a bubble chat that has these chat commands from everyone else EXCEPT for the chat command user (I use the new chat by the way)
(i aumse) You want a chat command in Roblox where only the player who used it sees the bubble, while everyone else dosent you need to handle it carefully because of how the new chat system replicates messages!!!
The idea is when a player sends a command you dont want it replicated to everyone. Instead you intercept it and display it only to the sender.
1. You can detect when a player types a command and then only respond to them:
local Players = game:GetService("Players")
Players.PlayerAdded:Connect(function(player)
player.Chatted:Connect(function(msg)
if msg:sub(1,1) == "/" then -- detect command
player:SendNotification({
Title = "Command Executed",
Text = "You typed: "..msg,
Duration = 3
})
-- hide the chat bubble for others
end
end)
end)
2. For the new chat system you can intercept messages (i think) and suppress them for everyone except the sender:
local ChatService = require(game:GetService("ServerScriptService"):WaitForChild("ChatServiceRunner"):WaitForChild("ChatService"))
ChatService.SpeakerAdded:Connect(function(speakerName)
local speaker = ChatService:GetSpeaker(speakerName)
speaker.MessagePosted:Connect(function(message, channel)
if message:sub(1,1) == "/" then
-- remove message from everyone else
for _, otherSpeaker in pairs(ChatService:GetSpeakerList()) do
if otherSpeaker ~= speakerName then
local other = ChatService:GetSpeaker(otherSpeaker)
other:RemoveMessage(message)
end
end
end
end)
end)
In practice many people use RemoteEvents to display the command message only to the player who ran it skipping replication entirely. That way the chat bubble never appears for others!
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.