How to check if an instance has a child in it?

exactly what the title says, how can i check if an instance has a child in it?
and if found then return true

1 Like
local function HasChild(ToCheck)
    if #ToCheck:GetChildren() > 0 then -- Check if the table of the part's children has more than 0 components
        return true
    else
        return false
    end
end

You could also reduce it down to just

local function HasChild(ToCheck)
    return #ToCheck:GetChildren() > 0
end
1 Like

it worked than you very much!!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.