Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why does my region detect no players while also detecting players?

Asked by 2 years ago
local part = game.Workspace.focusPart
local pos1 = part.Position - (part.Size/2)
local pos2 = part.Position + (part.Size/2)
local region = Region3.new(pos1, pos2)
local ignoreList = {part, game.Workspace.Baseplate}
local hint = Instance.new("Hint", game.Workspace)
while true do
    wait(2)
     regionFind = workspace:FindPartsInRegion3WithIgnoreList(region, ignoreList, math.huge)
    for i, parts in pairs(regionFind) do 
        if parts.Parent:FindFirstChild("Humanoid") then 
            print("found player")
            part.BrickColor = BrickColor.new("Bright green")
            hint.Text = "Player in team base!"
            print("running")
        else 
            print("no player")
        end
    end
end 

when i step into the region is changes to green while also changing the hint text to player found however it also prints "no" even tho there is an else. why does it still continue into the else part of the code even when the player is in the region? Ive tried making another conditional checking if no players where in the region, but it was no help

Answer this question