Chatted (Event): Difference between revisions

From Legacy Roblox Wiki
Jump to navigationJump to search
>NXTBoy
Fixed
>Merlin11188
No edit summary
 
(18 intermediate revisions by 5 users not shown)
Line 1: Line 1:
== In [[Player]] ==
{{:Chatted (Event)/player}}
{{:Chatted (Event)/player}}
{{clear floats}}
This event is fired whenever the player types in a chat bar or selects a phrase in the conversation pop-up. The ''msg'' contains the text from the chat box. In the case of the conversation pop-up, the msg contains "/sc " followed by the message code. The recipient argument is always nil.
{{Example|<pre>
function onChatted( message )
  if message == "respawn" and game.Players.LocalPlayer.Character then
      game.Players.LocalPlayer.Character:BreakJoints()
  end
end
game.Players.LocalPlayer.Chatted:connect( onChatted )</pre>}}
=== Limitations ===
*Player.Chatted must be used from Server-side scripts. It does not fire in LocalScripts.
== In [[Chat]] ==
{{:Chatted (Event)/chat}}
{{:Chatted (Event)/chat}}
{{clear floats}}
{{clear floats}}
This is event is fired whenever the [[Chat (Method)|Chat Method]] is used.  It returns the exact same arguments that were used to call the method.


{{Example|
== Usage ==
If using the [[Command Bar]] or a [[CoreScript]]...<pre>
Please note that the recipient value is always nil. This is an example of connecting the chatted event to all incoming players.
game.Chat.Chatted:connect( function( head, message, chatcolor )
  print( "HEAD: " .. head )
  print( "MESSAGE: " .. message )
  print( "CHATCOLOR: " .. chatcolor )
end)
 
game.Chat:Chat( Workspace.Player.Head, "This is a chat!", Enum.ChatColor.Blue )
</pre>
Will result in<pre>
HEAD: Head
MESSAGE: This is a chat!
CHATCOLOR: Enum.ChatColor.Blue</pre>
If using a [[Script]] or [[LocalScript]]...
<pre>
<pre>
game.Chat.Chatted:connect( function( head, message, chatcolor )
Game.Players.PlayerAdded:connect(function(player)
  print( "HEAD: " .. head )
  player.Chatted:connect(function(msg)
  print( "MESSAGE: " .. message )
    if msg == "reset" then
  print( "CHATCOLOR: " .. chatcolor )
      player.Character:BreakJoints()
    end
  end)
end)
end)
</pre>
</pre>
Will result in<pre>
 
s Chatted</pre>}}


[[Category:Events]]
[[Category:Events]]

Latest revision as of 23:00, 18 July 2011

Chatted ( String message, Instance recipient )
Description Fired when the owning player types a chat in chat bar or selects a phrase in safe chat menu.
Member of: Player
Chatted ( Instance head, String message, ChatColor chatColor )
Description Fired when Chat Method is used.
Member of: Chat


Usage

Please note that the recipient value is always nil. This is an example of connecting the chatted event to all incoming players.

Game.Players.PlayerAdded:connect(function(player)
  player.Chatted:connect(function(msg)
    if msg == "reset" then
      player.Character:BreakJoints()
    end
  end)
end)