My code works fine but there is way too much checking involved and doesn't even include the part's X or Z orientation.
The variable that needs changing is the PartXChange and PartZChange. I have another variable called PartYChange I just haven't included it
These 3 variables are for where the part's size (x,y,z) are relative to another part
if boundary then
print(Part.Orientation.Z)
print(Part.Orientation.X)
if Part.Orientation.Y <= -90 then --Starts check here
PartXChange1 = Part.Size.Z
PartXChange2 = -Part.Size.Z
elseif Part.Orientation.Y <= 0 then
PartXChange1 = -Part.Size.X
PartXChange2 = Part.Size.X
elseif Part.Orientation.Y <= 90 then
PartXChange1 = Part.Size.Z
PartXChange2 = -Part.Size.Z
elseif Part.Orientation.Y <= 180 then
PartXChange1 = -Part.Size.X
PartXChange2 = Part.Size.X
end
if Part.Orientation.Y <= -90 then
PartZChange1 = Part.Size.X
PartZChange2 = -Part.Size.X
elseif Part.Orientation.Y <= 0 then
PartZChange1 = -Part.Size.Z
PartZChange2 = Part.Size.Z
elseif Part.Orientation.Y <= 90 then
PartZChange1 = Part.Size.X
PartZChange2 = -Part.Size.X
elseif Part.Orientation.Y <= 180 then
PartZChange1 = -Part.Size.Z
PartZChange2 = Part.Size.Z
end --Ends here
local v3 = boundary.CFrame:PointToObjectSpace(Part.Position)
if math.abs(PartXChange2 / 2 + v3.X) <= boundary.Size.X / 2 and math.abs(Part.Size.Y / 2 + v3.Y) <= boundary.Size.Y / 2 and math.abs(PartZChange1 / 2 + v3.Z) <= boundary.Size.Z / 2 then
Inboundary = true
else
Inboundary = false
end
if math.abs(PartXChange1 / 2 + v3.X) <= boundary.Size.X / 2 and math.abs(-Part.Size.Y / 2 + v3.Y) <= boundary.Size.Y / 2 and math.abs(PartZChange2 / 2 + v3.Z) <= boundary.Size.Z / 2 then
Inboundary2 = true
else
Inboundary2 = false
end
I know this is kind of bland but the title says it all. So, how could I go about this?
