how to detect if part had children roblox

-- Step 1: Get the reference to the part you want to check for children.
local part = workspace.Part -- Replace "Part" with the actual name of your part.

-- Step 2: Use the :GetChildren() method to get an array of the part's children.
local children = part:GetChildren()

-- Step 3: Check if the array of children is not empty to determine if the part has children.
if #children > 0 then
    -- Part has children.
    print("The part has children.")
else
    -- Part does not have children.
    print("The part does not have children.")
end