ive just done a simple register form where i can check username exists and before i put the username exists in the register works but when i have the username check in it doesnt work can someone check this over for me the script and error log are as follows:

with username check included

<?php require 'Connections/connections.php'; ?>
    if(isset($_POST['register'])) {

       $username = mysqli_real_escape_string($conn, $_POST['username'];
       $email = mysqli_real_escape_string($conn, $_POST['email'];
       $password = mysqli_real_escape_string($conn, $_POST['password'];

       $storePassword = password_hash($password, PASSWORD_BCRYPT, array('cost' => 10));

       //username check start      
       $username = mysqli_query($conn,"SELECT username FROM users WHERE username='$username'");
       $count = mysqli_num_rows($username);


        die("Username already exists! Please type another username");
       //username check finish

       $sql = mysqli_query($conn,"INSERT INTO users (username, email, password)VALUES('{$username}','{$email}','{$storePassword}')");

       header('Location: login.php');

and error log is

PHP Catchable fatal error:  Object of class mysqli_result could not be converted to string in

if anyone can see whats causing this be much appreciated ty jan x

ok was querying the die ill sort that hun and ill use the else ty for geting back hun

The only Hun I want to be called today is Attila.

ok sorry its the way i speak but ty for your sugguestion