Turret Angles / Player Positioning.

Hello Facepunch,
for a few days now i’ve been struggling to fix an issue I’m having, that issue is well… I cannot get my turret to face me, I’m unable to get the turrets angles to face me when I step inside the radius.
I’d apprecaite it if anyone could help me upon this.

Thanks ever so much,

[LUA]

function ENT:Think()

for _, ent in pairs( ents.FindInSphere(self.Entity:GetPos(), 90) ) do
if ent:IsPlayer() and ent:Alive() then
local plrPos = ent:GetPos()
local shootAngles = self.gun:GetAngles()
local shootDir = shootAngles:Forward()

self.gun:SetAngles(Angle(0,ent:GetPos().X,0) )

end
end

end

[/LUA]

(self:GetPos()-ent:GetPos()):Angle()

There’s also this

Entity:PointAtEntity

I’d agree with you on that but the issue with using that method is this function will make the turret look at the players origin point, i.e their feet.

[editline]30th August 2016[/editline]

Where would I put this exactly?

in there

Thanks, it works!
Can you explain why the extra brackets are needed, I don’t get why they are.
[LUA]
self.gun:SetAngles( '('ent:GetPos()-self.gun:GetPos() ‘)’:Angle() )
[/LUA]