Region3 isn't precise or not detecting player parts

Hello!
So I have a bank system, and I have a big transparent part, covering it, so basically, when the bank rob stops, it should ‘Kick’ or move all the players outside, but it doesn’t works, I mean, the region isnt detecting them right…

This is the code, yes i’m doing it 5 times, just to make sure


This is region part

	for i = 1,5 do
			   local Region = Region3.new(workspace.Map.Bank.Region.Position - (workspace.Map.Bank.Region.Size), workspace.Map.Bank.Region.Position + (workspace.Map.Bank.Region.Size))
			local PartsinRegion = workspace:FindPartsInRegion3(Region)
			for i,v in ipairs(PartsinRegion) do
				if v.Parent:FindFirstChild('Humanoid') then
					local plr = game.Players:GetPlayerFromCharacter(v.Parent)
					if plr then
						plr.Character:MoveTo(workspace.Map.Bank.OutPart.Position)
					end
				end
			end
			end

This is what happens: https://gyazo.com/c7831d53024388ae804a4e77646c640e
Yes, exactly… nothing :confused:

This is probably because it is not detecting more than 20 parts:

workspace:FindPartsInRegion3(Region)

Change that to:

workspace:FindPartsInRegion3(Region, nil, 100) -- you can change 100 to math.huge if you want to
2 Likes

Hey so, i changed it, and it worked, BUT, sometimes it doesn’t works, I don’t know why

It’s probably because your region is huge:

 local Region = Region3.new(workspace.Map.Bank.Region.Position - (workspace.Map.Bank.Region.Size), workspace.Map.Bank.Region.Position + (workspace.Map.Bank.Region.Size))

You have to halve the size or else it will be 2x bigger then you would expect:

 local Region = Region3.new(workspace.Map.Bank.Region.Position - workspace.Map.Bank.Region.Size/2, workspace.Map.Bank.Region.Position + workspace.Map.Bank.Region.Size/2)

You should also try not to loop it 5 times.

1 Like