Ad
Log in to vote
0

How to detect if a player is not inside of a Region3?

Asked by 6 days ago

Here is the current code:

local region = Region3.new(Vector3.new(0,0,0), Vector3.new(182.25, 67, 101.75))

local player = game:GetService("Players")

local part = Instance.new("Part")
part.Anchored = true
part.Size = region.Size
part.Position = part.Position + Vector3.new(8.375, 24.25, 42.875)
part.Parent = game.Workspace
part.CanCollide = false
part.Transparency = 0.5

local found = false

while true do
    wait()
    local partsInRegion = workspace:FindPartsInRegion3(region, part, 1000)
    for i, part in pairs(partsInRegion) do
        if part.Parent:FindFirstChild("Humanoid") ~= nil then
            print("Player is inside")
        end
    end
end

1 answer

Log in to vote
0
Answered by 6 days ago

Use else:

if part.Parent:FindFirstChild("Humanoid") ~= nil then
    print("Player is inside")
else
    print("Player is outside")
end

0
Hmm I tried that and it didn't work. It prints both of them at the same time? VelocityVH 6 — 6d
0
Huh, strange.. SEAN_YT213 104 — 6d
Ad

Answer this question