Hello! I was just wondering if thrre is a way to cancel the output of what you type in the chat.
For example if you type in "help", it will cancel it, players wouldnt be able to see the message but it will do something.. like play a sound of a tutorial. I already have a script.
voicehelp = script.Sound game.Players.PlayerAdded:connect(function(plr) plr.Chatted:connect(function(message) If message == "help" voicehelp:Play()
My question is what should I add to the script to prevent the "help" message going into the chat.
I did code in a different game, there I could use "cancel event" so the message wont be executed but I could do different stuff after you type in the message.
if
and end)
. You are also missing a then
, as well as an end
to finish your if
chunk. Let me fix your code.local voiceHelp = script.Sound -- use local variables game:GetService("Players").PlayerAdded:Connect(function(player) player.Chatted:Connect(function(msg, recipient) if msg == "/e help" and not recipient then -- if they are not whispering voiceHelp:Play() end -- you were missing an end end) end)
Connect
, as ROBLOX may remove connect
in the future.Hi Dannie,
local message_holder = script.Parent:WaitForChild("Chat"):WaitForChild("Frame"):WaitForChild("ChatChannelParentFrame"):WaitForChild("Frame_MessageLogDisplay"):WaitForChild("Scroller"); -- The Frame that holds the messages local texts = { -- The texts that you want to dissapear. "help"; "blah"; "remove me"; "i hate myself"; } function remove_message(child) -- The function, child is the Instance that is added to the message holder. local frame = child; local txt_label = frame:WaitForChild("TextLabel"); -- The TextLabel that has each players' message inside. local text = txt_label.Text:lower(); -- The message that was added, in lowercase. for _, txt in next, texts do -- Loop through all of the texts to see if any of them match what's inside the message that was added. if text:match(txt) then -- If they match, then frame:Destroy(); -- It gets destroyed end end end message_holder.ChildAdded:Connect(remove_message); -- Connecting the .ChildAdded function to the Event.
Thanks,
Best regards,
~~ KingLoneCat