Okey, so im making a little gamemode, and is not derived in sandbox. (Not sure if it has anything to do with it, but anyways…)
I’ve added the antlion hat (from the hat mode) to the entities and i’ve tried to spawn it… it spawns, i use it, and then this awful error burns my eyes from the console:
entities/antlion_head/cl_init.lua:24: attempt to call method 'GetRagdollEntity' (a nil value)
this is the code:
[lua]
include(“shared.lua”)
function ENT:Think()
if self.Entity:GetOwner():GetNWBool(“Camera”) == true then
if LocalPlayer() == not self.Entity:GetOwner() then
self.Entity:SetColor(255,255,255,255)
elseif LocalPlayer() == self.Entity:GetOwner() then
self.Entity:SetColor(255,255,255,255)
end
elseif self.Entity:GetOwner():GetNWBool(“Camera”) == false then
if LocalPlayer() == not self.Entity:GetOwner() then
self.Entity:SetColor(255,255,255,255)
elseif LocalPlayer() == self.Entity:GetOwner() then
self.Entity:SetColor(0,0,0,0)
end
end
end
function ENT:Draw()
local owner = self.Entity:GetOwner()
if owner:GetRagdollEntity() then
owner = owner:GetRagdollEntity()
elseif not owner:Alive() then return end
local boneindex = owner:LookupBone("ValveBiped.Bip01_Head1")
if boneindex then
local pos, ang = owner:GetBonePosition(boneindex)
if pos and pos ~= owner:GetPos() then
self.Entity:SetPos(pos + ang:Forward()*6 + ang:Right()*4)
ang:RotateAroundAxis(ang:Up(),90)
ang:RotateAroundAxis(ang:Forward(),270)
ang:RotateAroundAxis(ang:Right(), 180)
self.Entity:SetAngles(ang)
self.Entity:DrawModel()
return
end
local attach = owner:GetAttachment(owner:LookupAttachment("eyes"))
if not attach then attach = owner:GetAttachment(owner:LookupAttachment("head")) end
if attach then
self.Entity:SetPos(attach.Pos)
self.Entity:SetAngles(attach.Ang)
self.Entity:DrawModel()
end
end
end
[/lua]