Region3.new Issue

Since I think region3 is better for me so I decided use it anyways, but I don’t understand what’s wrong with the code?
For e.x you can walk at medium part which is works weird, the large is decent, small is decent too!

Anyone have a good alternative to use?

function isOn(part,plr)
	local min = part.Position - (.5 * part.Size)
	local max = part.Position + (.5 * part.Size)	
	local region = Region3.new(min,max):ExpandToGrid(1)
	while task.wait() do
		local parts = game.Workspace:FindPartsInRegion3(region,part,math.huge)
		for i,v in pairs(parts) do
			local parent = v.Parent
			if parent:FindFirstChild("Humanoid") and parent:FindFirstChild("Humanoid").MoveDirection ~= Vector3.new(0,0,0) and parent:FindFirstChild("Humanoid").Health > 0 then
				part.BrickColor = BrickColor.new("Really black")
				plr.object.Value = part
				break
			else
				part.BrickColor = BrickColor.new("Institutional white")
				if plr.object.Value == part then
					plr.object.Value = nil
				end
			end
		end
		if #parts == 0 then
			part.BrickColor = BrickColor.new("Institutional white")
		end
	end
end

for _, v in pairs(workspace.level10:GetChildren()) do
	v.Touched:Connect(function(hit)
		if hit.Parent.Humanoid then
			local player = game.Players:GetPlayerFromCharacter(hit.Parent)
			player.object.Value = v
			isOn(v,player)
		end
	end)
end

PartColor.rbxl (26.9 KB)

You can’t use Region3 on rotated parts, because Region3s are only calculated given 2 points in the workspace and nothing else. Use the ZonesPlus API instead.

image

Try to point with both of your hands, pretend that those points are min and max, and imagine those points on opposite positions of a cube. It won’t make sense to rotate it, but if it’s only facing one direction then you’ll be able to understand why this is the case.

1 Like

I already realized this when I checked the hitbox. Also I don’t know how ZonesPlus works and would it fit with my function.

The documentation is right there. If you’re able to know what Region3s are then you should be able to know how to refer to the documentation. It isn’t difficult, I promise. If you don’t know about module scripts that well then look into those too.

I get it, but is there really no other way besides this? I’m too lazy to use that I don’t know.

No, there probably isn’t. You’ll be okay.

I’ve had an issue with region3 before, just use region3 whitelist and whitelist the character