Umm why is this not working? Simple code

game.Players.PlayerAdded:Connect(function(player)
	wait(0.5)

	local char = player.Character
	local human = char:FindFirstChild("Humanoid")
	local region = Region3.new(game.Workspace.Part1.Position, game.Workspace.Part2.Position)
	
	while true do
		local regionParts = game.Workspace:FindPartsInRegion3(region)
			print(regionParts)
			wait(1)
			
	end
end)

WHYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY

(it prints out nothing)

change that to

local char = player.Character or player.CharacterAdded:Wait()
local human = char:WaitForChild("Humanoid")
1 Like

it still says nothing is in the table?

Additionally debug the region 3 and make sure you set up the part’s position properly and that stuff is indeed in the region. This function should help.

local function visualizeRegion3(region3 : Region3)
	local regionVisualizer = Instance.new("Part")
	regionVisualizer.Transparency = 0.5
	regionVisualizer.Name = "rV"
	regionVisualizer.Anchored = true
	regionVisualizer.Size = region3.Size
	regionVisualizer.CFrame = region3.CFrame
	regionVisualizer.Parent = workspace
	game.Debris:AddItem(regionVisualizer,0.5)
end
1 Like

oh snap your right LOL, it’s weird cause…
the visualizer says its 2d
weird, I’ll try to fix it!

That is probably because Region3 expects a minimum and maximum vector

Region3.new ( Vector3 min, Vector3 max )

Note that the order of the provided bounds matters: by switching them, the polarity of the Size components will switch. It is possible to create a Region3 with a negative volume .

The xyz values for the second vector should be greater than the xyz values for the first vector like ((0,0,0)min ,(5,5,5) max). Personally, haven’t run into this issue so I guess just try adjusting the part positions till you get it.

oh, then that’s it…
I didn’t even know that lol.
Thanks!

okay it works now thanks!

also i learned something new :smiley: