Entity network variable not working as it should?

Hello! I’m doing a entity which when e-pressed it will open a derma menu. Then that derma menu will config some parameters and then do some stuff.

The issue i’m having is not very complicated i guess, but i’m failing and my hangover it’s killing me, so i cant find what’s wrong. The first time i click E on the entity, it works as intended but then it will stop working.

This is the fragment of the code that’s being executed for this.

Init.lua
[lua=“init.lua”]
function ENT:Use(activator, caller)

self:SetEntityUsed(true)

end

function ENT:Think()

if self:GetScanExecute() then

	self:ExperimentalScan() // custom function, does not interfere.
	self:SetScanExecute(false) // NetVar
end

end
[/lua]
cl_init.lua
[lua=“init.lua”]
function ENT:Think()

	self:SetElevationCorrection(sliderValue)

	if self:GetEntityUsed() == true then

		self:Derma() // Opens the derma.

		self:SetEntityUsed(false) // Resets the netvar so it wont spawn derma's
	end

end
[/lua]
shared. lua
[lua=“shared”]

function ENT:SetupDataTables()

self:NetworkVar( "Bool", 0, "EntityUsed" )
self:NetworkVar( "Vector", 0 ,"FixedPos")
self:NetworkVar( "Int", 0 ,"ElevationCorrection")
self:NetworkVar( "Bool", 1 , "ScanExecute")

end
[/lua]

Edit: The code would execute on this order: ent use-> ent think (cl) ->ent think (sv)

Thanks for the help in advance :slight_smile:

You shouldn’t set network vars client side, it won’t change the server side value and will probably have unpredictable behavior client side. I recommend using a net message to open the derma panel.

Now i need to sent a message back and is not working, And the server is not receiving it. Also will this message sent from entity go to all the server or just to the init file of the entity, so it wont execute this on same type of entitys if spawned.

Maybe the reason is that the function being called ( ExperimentalScan ) is ENT:ExperimentalScan?

[lua]
util.AddNetworkString(‘BoatMenu’)
util.AddNetworkString(‘ScanExecute’)

net.Receive(‘ScanExecute’, ExperimentalScan )[/lua]

[lua]

	button.DoClick = function()

		net.Start('ScanExecute')
		net.SendToServer()
	end

[/lua]

The button does works, already checked.