Why doesn't this work

local hitbox = script.Parent.magicForestHitbox

while wait() do
	local players = game.Players:GetPlayers()
	local region = Region3.new(hitbox.Position - (hitbox.Size/2), hitbox.Position + (hitbox.Size/2))
	
	local parts = game.Workspace:FindPartsInRegion3(region)
	for i, v in pairs(parts) do
		if v.Name == "Head" then
			if v.Parent:FindFirstChild("Human") then
				--call remote event with v.parent.name
				print("player found")
				plr = table.find(players, v.Parent.Name)
				table.remove(players, plr)
			end
		end
	end
	--loop through players calling remote event to stop music
	print("player not in region3")
end

There’s no error it just… doesn’t work. It prints “player in region3” sometimes when I’m in the region, sometimes when I’m not… stuff just prints at the wrong times- it’s weird.

EDIT: I did a test, and the region is the correct size, shape, position, whatever, all of that I’m 99% certain is perfect. So why isn’t this working?

Shouldn’t this be “Humanoid”?

v.Parent:FindFirstChild("Humanoid")

No, there’s a value inside the player I named “Human” to verify that the humanoid inside the region3 is a player, and not an NPC.


The region is the size of the bounding box of this model here


Yet it only seems to work within the green area.

I also used scripts to create a new part with the same size and cframe as the region, and it’s size and cframe was exactly the size and cframe i wanted it to be so

I can’t say for sure why it isn’t working, I use zone v2 module to handle this sort of stuff for me

the only alternative I could tell you is testing:

try inserting a part (and possibly group it into a standalone model, make it the same size and test if it works :man_shrugging:

while task.wait() do
	local players = game.Players:GetPlayers()
	local region = Region3.new(hitbox.Position - (hitbox.Size/2), hitbox.Position + (hitbox.Size/2))
	
	local parts = game.Workspace:FindPartsInRegion3(region)
	for i, v in pairs(parts) do
		if v.Name == "Head" then
			if v.Parent:FindFirstChild("Human") then
				--call remote event with v.parent.name
				print("player found")
				plr = table.find(players, game.Players:GetPlayerFromCharacter(v.Parent))
				table.remove(players, plr)
			end
		end
	end
	--loop through players calling remote event to stop music
    for i, v in pairs(players) do
        print(v.Name.." is not in region")
    end
end