The do IsFirst() … end isn’t required.

Syntaxically ply:IsFirst doesn’t make any sense. First of all you haven’t called the function, which means it would be ply:IsFirst(), secondly the player doesn’t have an IsFirst function, you’d need to find the metatable if you wanted to do it like that, third the IsFirst function doesn’t take any parameters, so even if you got it into the player table doing ply:IsFirst() would have the same result as ply.IsFirst() and simply IsFirst()

Here’s a function to tell if two players are in a radius.

[lua]-- p1 is the first player, p2 is the second and r is the radius they must be in

local function playersInRadius(p1, p2, r)

return p2:GetPos():Distance(p1:GetPos()) < r

end[/lua]

To check if each player is in the radius you might need a hook in think

[lua]

– fill these in yourself

local PERSONAL_SPACE_RADIUS

local PERSONAL_SPACE_TIME_LIMIT

local inRadiusStart = {}

hook.Add(“Think”,“PersonalSpaceDude”,function()

local allPlayers = player.GetAll()

for i, p1 in ipairs(allPlayers) do

inRadiusStart[p1] = inRadiusStart[p1] or {}

for j, p2 in ipairs(allPlayers) do

if j > i then – so we don’t repeat pairs of players

– if you’re in the radius

if playerInRadius(p1, p2, PERSONAL_SPACE_RADIUS) then

– and you’ve already checked the radius before

if inRadiusStart[p1][p2] then

– check if you’ve been in there too long

if CurTime() > inRadiusStart[p1][p2] + PERSONAL_SPACE_TIME_LIMIT then

– do whatever if they’re together too long

end

– if you haven’t checked the radius before

else

– set the time

inRadiusStart[p1][p2] = CurTime()

end

– if you’re not in the radius but you’ve been in the radius

elseif inRadiusStart[p1][p2] then

– unset the time to say you’ve left the radius

inRadiusStart[p1][p2] = nil

end

end

end

end

end)[/lua]

There’s probably a few optimizations that could be done and ideally the inRadiusStart table and subtables should have weak keys, but it should do what you’re asking for.