Kotlin app crashes when switching activity

Hello, i have a problem with switching activitys in my app. I made a button that switches the activitys but everytime i press the button my app crashes. Android studio also gave me a few error codes. I have these in a screenshot and also the code for the activity switch. Would be great if someone could help.

 override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)
        val MainActivity2 = findViewById<Button>(R.id.button)
        MainActivity2.setOnClickListener {
            val Intent = Intent(this,MainActivity2::class.java)
            startActivity(Intent)
        }

Here you’re declaring a variable called MainActivity2, which is a button.

Here you’re trying to launch an activity whose class is the class of the button you’ve declared above.

As the error message says there isn’t an activity whose class is MaterialButton. You need to pass the class of your activity.

I think you’re just shadowing the class name here with that local variable. Just call your button “button” and that should work.