Now I know this is going from client to server to client. If you're doing it just by command you can do it straight from the server.
But since you want to do it through a gui, this is an example of how you could do it:
Client-side:
addCommandHandler("msg",
function(_,playerName,...)
if not playerName then
outputChatBox("No player name given")
return
end
if #arg == 0 then
outputChatBox("No message given")
return
end
local player = getPlayerFromName(playerName)
if player then
local message = table.concat(arg," ")
triggerServerEvent("printMsg",localPlayer,player,message)
end
end
,false,false)
addEvent("onMsg",true)
addEventHandler("onMsg",root,
function(msg)
sender = getPlayerName(source)
message = msg
if isTimer(receiveTimer) then
resetTimer(receiveTimer)
else
addEventHandler("onClientRender",root,drawMessage)
receiveTimer = setTimer(function()
removeEventHandler("onClientRender",root,drawMessage)
sender,message = nil,nil
end,5000,1)
end
end
)
function drawMessage()
dxDrawText("A message from "..sender..":", 15, 324, 279, 360, tocolor(255, 255, 255, 255), 1.50, "default", "left", "top", false, false, false, false, false)
dxDrawText(message, 15, 368, 279, 529, tocolor(45, 203, 78, 255), 1.50, "default", "left", "top", false, true, false, false, false)
end
Server-side:
addEvent("printMsg",true)
addEventHandler("printMsg",root,
function(player,message)
triggerClientEvent(player,"onMsg",source,message)
end
)