Help with Lua Script.

Hello, I’m trying to make a script that sends a welcome message when a player join.

local function SendMessage( ply )
local nick = ply:IsConnected():GetName()
local Hostname = GetHostName()
local message = "Hi there" .. nick .. " welcome to "  .. Hostname ..  " enjoy your stay!"
	if  ( ply:IsConnected ) do
		ply:PrintMessage( HUD_PRINTCENTER, message )
hook.Add("PlayerWelcomeMessage", "playerwelcomemessage", SendMessage)

Can anyone help?

Thank you,


hook.Add(“PlayerInitialSpawn”, “Init_WelcomeMessage”, function(ply)
ply:PrintMessage( HUD_PRINTCENTER, “Hi there " … ply:Nick() … " welcome to " … GetHostName() … " enjoy your stay!” );

You should really look into using user messages and send them through this hook.

Thank you for helping. Going to try it now. I got the script from the wiki.


Please don’t sign your posts.

Go be a troll else-where, please.

I’m quite happy here thank you.