Region3withwhitelist not working

Hello my fellow robloxians.
I am working on a game called Project Binary, There i have an airlock and if your heading towards the core you will get less gravity.
The way i am doing it right now is Have a list of the characters. and then check with region3withwhitelist and then make it a userlist that then i give every character less gravity using a bodyforce,

What my problem is the FindPartsInRegion3WithWhiteList Isnt working. even tho there’s nothing wrong i can see. i have tested my code and everytime it leads back towards the region3.

Here’s a snipped of my code


local BottomLeftCornor = Vector3.new(-168.367, 495.781, -360.271)
local TopRightCorner = Vector3.new(-199.667, 513.681, -320.669)

local whitelist = {}
	for _, player in pairs(game.Players:GetPlayers()) do
		if player and player.Character then
			table.insert(whitelist, player.Character)
		end
	end		

	local Inside = workspace:FindPartsInRegion3WithWhiteList(Region3.new(BottomLeftCornor,TopRightCorner),whitelist,1000)
	
	for i,v in pairs(Inside) do
		wait(i,v)
	end
	
	local Users = {}
	for _, player in pairs(game.Players:GetPlayers()) do
		for _,Part in pairs(Inside) do
			if Part:IsDescendantOf(player.Character) then
				table.insert(player.Character) 
				break
			end
		end
	end

anyone knows what to do

When printing out the size of the Region3 we get (-31.3000031, 17.9000244, 39.6019897) we shouldn’t see any negative values here. So the problem is your BottomLeftCorner and TopRightCorner positions.

Region3’s operate off of two Vector3’s. The first is the minimum position and the second is the maximum position. Since your values are:

local BottomLeftCornor = Vector3.new(-168.367, 495.781, -360.271)
local TopRightCorner = Vector3.new(-199.667, 513.681, -320.669)

and BottomLeftCorner is your minimum vector and TopRightCorner is your maximum vector we can see that -168.367 in BottomLeftCorner is greater than -199.667 in TopRightCorner

If you swap the X’s in both of these vectors then your Region3 will work as expected.

local BottomLeftCornor = Vector3.new(-199.667, 495.781, -360.271)
local TopRightCorner = Vector3.new(-168.367, 513.681, -320.669)

Should be correct :slight_smile:

2 Likes

thanks, i thought it just required 2 positions. roblox should really start listing thier things better.

They do a pretty good job on their wiki: https://www.robloxdev.com/api-reference/datatype/Region3 outlines pretty much exactly what I described. It would be nice if maybe an error were thrown when a negative size is input though!

Well actually that API reference I gave does leave a lot to be desired haha.

1 Like

still not returning any parts.

Hmm… odd, it seems to be working on my end. Mind posting your updated code?

local BottomLeftCornor = Vector3.new(-199.667, 495.781, -360.271)
local TopRightCorner = Vector3.new(-168.367, 513.681, -320.669)

local whitelist = {}
	for _, player in pairs(game.Players:GetPlayers()) do
		if player and player.Character then
			table.insert(whitelist, player.Character)
		end
	end		

	local Inside = workspace:FindPartsInRegion3WithWhiteList(Region3.new(BottomLeftCornor,TopRightCorner),whitelist,1000)
	
	for i,v in pairs(Inside) do
		warn(i,v)
	end
	
	local Users = {}
	for _, player in pairs(game.Players:GetPlayers()) do
		for _,Part in pairs(Inside) do
			if Part:IsDescendantOf(player.Character) then
				table.insert(Users,player.Character) 
				break
			end
		end
	end

What is this for?

R15 characters have 15 parts + hats so this could wait a very long time. Also, wait doesn’t take a second variable so I’m not sure what you’re trying to accomplish with this.

Unless there’s some reason that I don’t see to keep this then I would remove it. Essentially what this is doing is making it wait 1, then 2, then 3, then 4, then 5, then 6, then 7, … , then n seconds to move to the next step in your code which is what checks for players.

It’s likely that the code is actually working but you can’t see it working because of the long delay.

was ment to be warn, this is to check what players are in that area, forgot to change it to warn in this example. but still then it doesnt warn anything

Does this code run at run-time or is it in some sort of function wrapper and then it executes whenever the airlock is opened?

uts a function wrapper. i fire it only whenever they go throug the airlock sequence

We talked about this issue in a DM and determined that the code was working but there seemed to be some unrelated studio bug preventing the change from actually taking affect.