How do you have a part detect both humanoid and baseparts?

I’m trying to make my fireball detect both humanoid and baseparts, but right now it only detects humanoids:

newFireball.Touched:Connect(function(hit)
        if hit.Parent.Name ~= player.Name and hit:IsA("BasePart") and hit.Parent:FindFirstChild("Humanoid") then
newFireball.Touched:Connect(function(hit)
  if hit.Parent.Name ~= player.Name then
    if hit.Parent:FindFirstChild("Humanoid") then
       print("humanoid hit", hit.Parent.Name)
   else
      print("base part hit", hit.Name)
   end
end
end)

Try this:

newFireball.Touched:Connect(function(hit)
        if hit.Parent.Name ~= player.Name and (hit:IsA("BasePart") or hit.Parent:FindFirstChild("Humanoid")) then

you would probably want to change your if statement to or instead of and:

newFireball.Touched:Connect(function(hit)
        if hit.Parent.Name ~= player.Name and hit.Parent:FindFirstChild("Humanoid") or hit:IsA("BasePart")  then

if your checking if the part that touched is a players character i suggest trying this:

local function playerCheck(model:Instance)
    local checks = {"Humanoid";"HumanoidRootPart"}
    local valid = true
    for i,v in pairs(checks) then
        if model:FindFirstChild(v) == nil then
            valid = false
            break
        end
    end
    return valid
end

newFireball.Touched:Connect(function(hit)
    if playerCheck(hit.Parent) and hit.Parent.Name ~= player.Name then
        ...
    end
end)

feel free to ask anymore questions

local function ImTriggered(part)
     print(part)
end 

newFireball.Touched:connect(ImTriggered)

Please type this into studio, not copy and paste as I am on mobile rn and the spacing won’t be right

This will find both and show you them in the output this uses hardly any space, please specify if you want them to be detected for other reasons