im trying to figure out how would I know if a part is in bounds or inside a part. ive tried looking up questions about it, but none of them give a good answer than just "check if the position is in bounds of the part". If someone can give me an idea of how would i do that would be appreciated.

edit:

found a way to determine if its in bounds or not of a part:

local target = workspace.target
local corner1 = script.Parent.Position-script.Parent.Size/2
local corner2 = script.Parent.Position+script.Parent.Size/2

local function createPart(pos,name)
	local part = Instance.new("Part")
	
	part.Anchored = true
	part.Size = Vector3.new(2,2,2)
	part.CFrame = CFrame.new(pos)
	part.Name = name
	part.Parent = workspace
end

createPart(corner1, "1")
createPart(corner2, "2")

if corner1.Z <= target.CFrame.Position.Z and corner2.Z >= target.CFrame.Position.Z and corner2.X >= target.CFrame.Position.X  and corner1.X <= target.CFrame.Position.X then
	print("in bounds")
end

6 comments

0

I'm not sure what you are trying to do here...

0

But...the question is answered...

0

look at my question again mate

0

The simplest ways would just to use gettouchingparts() or region3

0

Use magnitude.