Get Player Model

I am trying to make a hat for my server and I need to fit it to every player model in the menu but I am having some trouble setting the pos relative to what model the player has. It seems to keep setting it to the first model in the if list which is alyx.

[lua]
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
		if owner:GetModel( "models/player/alyx.mdl" ) then
			self.Entity:SetPos(pos + ang:Forward()*1 + ang:Right()*-2.5)	
		elseif owner:GetModel( "models/player/barney.mdl" ) then
			self.Entity:SetPos(pos + ang:Forward()*1 + ang:Right()*-1.4)
		end

			
		ang:RotateAroundAxis(ang:Right(),-90)
		ang:RotateAroundAxis(ang:Up(),270)
		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]

Lines 12 to 16 should read:
[lua]if owner:GetModel() == “models/player/alyx” then
self.Entity:SetPos(pos + ang:Forward()1 + ang:Right()-2.5)
elseif owner:GetModel() == “models/player/barney” then
self.Entity:SetPos(pos + ang:Forward()1 + ang:Right()-1.4)
end[/lua]

I have tried that before and it moves the entity a massive amount off where it is supposed to be because it is not detecting the model.

You need to remove the extension (".mdl") as well.

Still a no go, tried my way with removing .mdl and it didn’t change the results.

entity.GetModel takes no arguments, so the way you did it originally is wrong.

The way I did it positions the hat as if I were not checking for a model, when I use the “correct” way it will not even let me change the position…

Try this:
[lua]if string.lower(owner:GetModel()) == “models/player/alyx” then
self.Entity:SetPos(pos + ang:Forward()1 + ang:Right()-2.5)
elseif string.lower(owner:GetModel()) == “models/player/barney” then
self.Entity:SetPos(pos + ang:Forward()1 + ang:Right()-1.4)
end[/lua]

Only way I could get it to work correctly was with nwstrings, will be fine for now.