Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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

Use else:

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

2 comments

0

Hmm I tried that and it didn't work. It prints both of them at the same time?

0

Huh, strange..

This discussion is preserved as it was. New answers, comments, and votes are closed.