title: GMod | Want to make a simple command that prints a colored message in the senders chatbox
body: <p>I just want to make a simple script that prints a colored text in the chat of the sender after executing a specific command.</p>
  
  <p>First the console gave me an error [attempt to index global 'chat' (a nil value)]. After reloading the Singleplayer and opening the script it didn't do anything. </p>
  
  <p>Current Code:</p>
  
  <pre><code>local ply = LocalPlayer()
  
  local function Test( ply, text, team )
      if string.sub( text, 1, 8 ) == "!command" then
          chat.AddText( Color( 100, 100, 255 ), "Test" )
      end
  end
  hook.Add( "PlayerSay", "Test", Test )
  </code></pre>
  
  <p>I hope that someone could help me.</p>