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

Region3 not detecting player?

EDIT: I solved this myself, you can see my answer below

So I was making a system where a label would pop up on the screen showing the location name if the player entered said location. It used to work until after I added the code to test if the player isn't in the area anymore. NOTE: It's not because of multiple locations. There are two of these scripts existing but I commented out the code to set it to "The Wilderness" from the other localscript and it still happened.

Code:

wait(5)
local player = game.Players.LocalPlayer
local Part1 = script.first
local Part2 = script.second

local region1Upper = Vector3.new(
	math.max(Part1.Position.X, Part2.Position.X),
	math.max(Part1.Position.Y, Part2.Position.Y),
	math.max(Part1.Position.Z, Part2.Position.Z))

local region1Lower = Vector3.new(
	math.min(Part1.Position.X, Part2.Position.X),
	math.min(Part1.Position.Y, Part2.Position.Y),
	math.min(Part1.Position.Z, Part2.Position.Z))
local region = Region3.new(region1Lower, region1Upper)
local inArea = false
while wait() do
	inArea = false
	for i,v in pairs(workspace:FindPartsInRegion3(region,nil,100)) do
		
        	if v.Parent.Name==player.Name then
	       		print (v.Parent.Name)
	    		game.ReplicatedStorage.AreaLabel.Value = "Home Base"
			inArea = true	
        	end
	end
		
	if game.ReplicatedStorage.AreaLabel.Value == "Home Base" and not inArea then
		game.ReplicatedStorage.AreaLabel.Value = "The Wilderness"
	end
end

1 answer

welp nevermind I fixed this by increasing the max amount of parts.

workspace:FindPartsInRegion3(region,nil,100)

doesn't get to the player because there are already more than 100 parts in the area.

workspace:FindPartsInRegion3(region,nil,1000)

this does get the player unless there are more than 1000 parts

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