Help with chat.Addtext

How would I make it so all players could see this?

	if ply:Alive() then
		ply:SendLua([[ chat.AddText( Color(0,102,0, 255), "[Respawn] ", Color(255, 255, 255, 255), LocalPlayer():Nick().." you must be dead to use that command!") ]])
	return end

if ply:Alive() then
   local pname = ply:Nick()
   for k, v in pairs( player.GetAll() ) do
      v:SendLua( [[chat.AddText(Color(0,102,0, 255), "[Respawn] ", Color(255, 255, 255, 255), "]] .. pname .. [[ you must be dead to use that command!") ]])

Didn’t test it, but it should work.

[editline]10th September 2013[/editline]

I guess code tags don’t like string literals

Thanks man worked like a charm! I tried something similar, I take it you HAD to add those extra []?

Thanks again!

You can escape the quotation marks on the inside like:

v:SendLua( "chat.AddText(\"words\")" )

v:SendLua( "chat.AddText(".. words .." )

What is that supposed to be? SendLua isn’t closed, words is going to try to be resolved as a variable, and you’re trying to concatenate an unclosed string at the end.

I assumed ]] … pname … [[ is to concatenate so I showed another way since he asked if all the ]] was required.