How can I check if a part left :GetPartsInPart()?

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve?
    I want to be able to tell when a part enters and then know when it leaves.

  2. What is the issue?
    Im able to detect when a part enters another part, however, I don’t know how to detect when that part leaves.

  3. What solutions have you tried so far?
    Yes, I googled and couldn’t find anything that would help me.

I am making my own placement system and everything is working, but, I need to detect when a part enters and leaves another part so I can tell if its eligible to place

If you need a better explanation please ask.

A snippet of code from my placement:

local function checkIfInPart(part, baseplate)
    local overlapParams = OverlapParams.new()
    
    for i, parts in ipairs(baseplate.Parent.parts:GetDescendants()) do
        if parts.Name == "Hitbox" then
            for i, v in pairs(workspace:GetPartsInPart(parts, overlapParams)) do
                if v ~= parts.Parent and v.Name ~= "Placeholder" then
                    
                end
            end
        end
    end
end

Im not sure if this is a good solution but it works, instead of using :GetPartsInPart() I just used :ArePartsTouchingOthers().

1 Like