I am attempting to make a join message as i prefer to make my own little scripts rather than using somebody else’s.
I’m having trouble getting this text from the client to user as chat.AddText is clientside
//serverside
AddCSLuaFile("cl_netlib.lua")
util.AddNetworkString("colorMsg")
local function PlayerJoined(ply)
if ply:IsPlayer() then
net.Start("colorMsg")
net.Send(ply)
end
end
hook.Add("PlayerInitialSpawn","spawnmsg", PlayerJoined)
//clientside
net.Receive("colorMsg",function()
chat.AddText(Color(255,0,0),ply:GetName(),Color(255,255,255)," has joined the server
")
end)
I am getting the following errors:
[ERROR] addons/maverick_joinmsg/lua/autorun/cl_netlib.lua:2: attempt to index global 'ply' (a nil value)
1. func - addons/maverick_joinmsg/lua/autorun/cl_netlib.lua:2
2. unknown - lua/includes/extensions/net.lua:32
[ERROR] addons/maverick_joinmsg/lua/autorun/sv_init.lua:3: attempt to call field 'AddNetworkString' (a nil value)
1. unknown - addons/maverick_joinmsg/lua/autorun/sv_init.lua:3