Purpose of '~= nil'

Hello everyone!

I was wondering what the purpose is of ‘~= nil’.

For example, I came across a teleportation script:

script.Parent.Touched:Connect(function(hit)
	local humanoid = hit.Parent:FindFirstChild("Humanoid")
	
	if humanoid ~= nil then 
		hit.Parent.HumanoidRootPart.CFrame = CFrame.new(workspace.TeleportParts["BluePart"].Position) + Vector3.new(0,3,0)
	end
end)

Why is ‘~= nil’ being used here? Because I could just write:

if humanoid then

Thnx in advance!