"Tried to use Null enitity!" in Net Messaging

I am currently attempting to make a DarkRP money printer, and attempting to make upgrade-able, While networking between the Client and Server this Error Appeared


 [ERROR] lua/entities/sentinel_printer/init.lua:51: Tried to use a NULL entity!
  1. Send - [C]:-1
   2. func - lua/entities/sentinel_printer/init.lua:51
    3. unknown - lua/includes/extensions/net.lua:32



I’ve tried rewriting the code in a different manner a few days ago but it still didn’t work. I’ve been told it’s because the receiving end is expecting an entity or is sending one, honestly I haven’t been able to wrap my head around that.

Client Code:




function speedpressed()

	net.Start("SpeedCommsServer")
	net.SendToServer("SpeedCommsServer")

end


net.Receive("SpeedLevelSuccess",function()

	notification.AddLegacy("You have upgraded your printer!",0,5)
	surface.PlaySound("common/stuck1.wav")

end)


net.Receive("SpeedLevelFailure",function()

	notification.AddLegacy("Your printer is already max level!",0,5)
	//surface.PlaySound("")

end)


The “SpeedPressed” is for a Derma button which sends a message to the server so it can do the logic and return whether the result to show the player.

Server:



AddCSLuaFile("cl_init.lua")	
AddCSLuaFile("shared.lua") 

util.AddNetworkString("UseDerma")
util.AddNetworkString("EntityOwner")
util.AddNetworkString("SpeedCommsServer")
util.AddNetworkString("SpeedCommsClient")
util.AddNetworkString("SpeedLevelSuccess")
util.AddNetworkString("SpeedLevelFailure")
include("shared.lua")


function ENT:Initialize()

	self:SetModel("models/props_c17/consolebox05a.mdl")

	self:PhysicsInit(SOLID_VPHYSICS)
	self:SetMoveType(MOVETYPE_VPHYSICS)	
	self:SetSolid(SOLID_VPHYSICS)

	self.timer = CurTime()

	local phys = self:GetPhysicsObject()

	if phys:IsValid() then

		phys:Wake()

	end	

	local printerowner = self:GetOwner()


end

printlvl = 10

net.Receive("SpeedCommsServer",function()

	if printlvl < 5 then

		printlvl = printlvl + 1

			net.Start("SpeedLevelSuccess")
			net.Send("SpeedLevelSuccess")


		elseif printlvl > 5 then

			net.Start("SpeedLevelFailure")
			net.Send("SpeedLevelFailure")

	end

end)


If anyone could come up with a solution and help that’d be much appreciated! This is not the full code, but these are the relevant parts of the code.

When calling net.Send from the server you don’t specify the message name, but instead a player object that you are sending it too. Check out the wiki page.

net.Send

The same applies for net.SendToServer, you dont need to specify the name as you already do that with net.Start.

Just to add to that, if you are trying to send to all players use net.Broadcast instead of net.Send

Thank you both so much, works perfectly.

Actually the net.Broadcast messed up my code, it upgrades all the printers on the server not just that one specific printer. I found a work around after trying to explain the issue to myself in a different way. So Null Entity means that the server doesn’t know to which Client it’s going to send it to, and it can not send it to all clients so to fix that in the ENT:Use(call) function I added a call and set it to the variable ply. So ply = call and in the net.Send() I put call between the brackets and it works fine. So net.Send(call). But thanks both for the help you’ve provided. (This is for anyone who might encounter the same issue that I did, hopefully it does assist them)