#how to check if the part is inside the boundaries

7 messages · Page 1 of 1 (latest)

true dove
#

I'm struggling to find a way to determine whether a part is within the boundaries of a plot, similar to construction games. I want to ensure that the part stays within the plot and doesn't extend beyond its limits. Essentially, I need to check if the part is completely contained within the plot.

just like in the image you could see that when the part are not fully inside the boundaries would be red else green

true dove
#

the only script I have right now that determines whether the part is in boundaries is this

local function checkBoundaries(plot, primary)
    local LowerXbound
    local LowerZbound
    local upperXbound
    local upperZbound

    local currentPos = primary.Position

    LowerXbound = plot.Position.X - (plot.Size.X*0.5)
    upperXbound = plot.Position.X + (plot.Size.X*0.5)

    LowerZbound = plot.Position.Z - (plot.Size.Z*0.5)
    upperZbound = plot.Position.Z + (plot.Size.Z*0.5)
    
    local check1 = currentPos.X > upperXbound or currentPos.X < LowerXbound or currentPos.Z > upperZbound or currentPos.Z < LowerZbound
    
    if check1 then
        outOfBounds = true
    else
        outOfBounds = false
    end
end```
#

but this only checks the mid point of a part and so It doesnt detect whether its fully inside the boundaries or not

velvet scroll
#

GetPartsInPart or GetPartsInRegion3 but here if you wanna check the offset, you can create a region3 per part, then check for size / 2 and at the center of the white part

tepid plinth
#

Region3 doesnt work anymore

velvet scroll