How to find a random position in X and Y coordinate in 90 degree cone behind a player?

I’ve tried this a few times, and even got a basic cone, but I have no idea on how to properly rotate it to face behind the player.

[lua]local playerPos = thePlayer:GetPos()
local playerAngle = thePlayer:GetAngles() --maybe EyeAngles() ?
local angle2d = playerAngle.y --get the yaw component of the angle
local behind = angle2d-180 --face the opposite direction
local randomBehind = behind+math.random(-45,45) --add a random 90 degrees to it
local distanceBehind = 100 --randomise this number as well?
local newAngle = Angle( playerAngle.p, randomBehind, playerAngle.r )
local newPos = playerPos + newAngle:Forward() * distanceBehind[/lua]


ang = pl:GetAngles( )

ang:RotateAroundAxis( ang:Up( ), 180 )
ang:RotateAroundAxis( ang:Up( ), math.Rand( -45, 45 ) )

pos = pl:GetPos( ) + ang:Forward( ) * distance

So that if the player is in any way rotated, it respects that.

Great, thanks!