Errors with derma-functions?

I am trying to kick a player using FAdmin via a derma text entry.

This is the code in question:


dte.OnEnter = function(self, tar, ply)
	ply:ConCommand("fadmin kick "..tar:SteamID().." "..dte:GetValue())
end

This gives me an error saying:


[ERROR] addons/darkrpmodification/lua/darkrp_modules/fp_adminstick/cl_adminstick.lua:27: attempt to index local 'ply' (a nil value)


I don’t see why it cannot find the ply entity. If I use tar:Kick(reason) then it just gives me the same error, with “tar” as the problem.

Any helps is appreciated :smiley:

tar and ply aren’t being passed to that function…

Oh sorry, forgot to add:

the piece of code in question is inside another function that has tar and ply defined.
I will add the full piece of code when I get home.

If they are defined previously in the function you say, then do this:


dte.OnEnter = function(self)
	ply:ConCommand("fadmin kick "..tar:SteamID().." "..dte:GetValue())
end

Because if you define them here, it gets overwritten and will just be nil

I see. Thanks a lot :smiley: