Find in box help

So i made this bit of code and the color of the box only updates when i move my mouse while im in the area i want to find players in.

Video:

Code:


local InBox = 0

hook.Add("HUDPaint", "SpawnNotify", function()
    if InBox == 1 then
        draw.RoundedBox(0,ScrW()/2,ScrH()/2+100, 50, 50, Color(0,255,0,255))
    else
        draw.RoundedBox(0,ScrW()/2,ScrH()/2+100, 50, 50, Color(255,0,0,255))
    end
end)




hook.Add("Think", "checkinbox", function()
    local EntsInBox = ents.FindInBox(Vector(-2927.851563, -32.067402, -511.968750), Vector(-1200.898560, -2063.968750, -178.487885))


    for _, v in pairs(EntsInBox)do
        if LocalPlayer() == v then
            InBox = 1
        else
            InBox = 0
        end
    end
end)

I’m on iPad so I cannot reply properly, but on your for loop you seet inbox to 1 only if the current entity is you. The problem is your are looping over a few entity, if you loop to e next entity and it isn’t the player then the inbox is going to be set back to 0. Only set inbox to 0 at the top of the think hook, not in the look and this should fix your issue. I’m sorry if the reply does not make sense but I’m awful at typing on ipad