Strange error in my SENT?

Hi. I’ve been making a SENT for a friend’s server and I keep getting a strange error when I spawn it. Can anyone help me figure out why it’s doing this?


function ENT:Initialize()
	ENT:SetModel("models/props/cs_office/plant01.mdl")
	ENT:SetSkin(0)
	ENT:PhysicsInit(SOLID_VPHYSICS)
	ENT:SetMoveType(MOVETYPE_VPHYSICS)
	ENT:SetSolid(SOLID_VPHYSICS)
	ENT:SetUseType(SIMPLE_USE)
	local phys = ENT:GetPhysicsObject()
	if phys and phys:IsValid() then phys:Wake() end
end

The above code in init.lue give me this:


[lua\entities\plant\init.lua:7] attempt to index global 'ENT' (a nil value)



(User was banned for this post ("Wrong section" - Gran PC))

Use ‘self’ rather than ENT.

So, it’d be like this:

Thank you! This solved the problem perfectly.

Hopefully you understand why, that is the most important part. No problem, however :slight_smile:

Is it because the function is part of ENT so its code needs to use self to refer to ENT?

Yeah! Bang on. I’d rather people learned than just copy+pasted and forgot about it!

Thanks. I’m new to Lua but I’m learning some now that I have a project to focus on.