Game crashes when detecting input

I am currently making a placement system to place some streets and buildings and recently I ran into the error, that if I try to get the input to place a street, Unity crashes completely (I always have to close it over my task manager).

The error came up, when I made some stuff for the streets to form road networks (for checking connections between buildings)

I dont really know, where the error occures, but I found out, that the function to get the input (I tried several methods for that) doesnt even get called. It just crashes right before the Update() function in this frame is called.

The strange thing is: First, I ran into this error, when I was doing it over mouse input, and it worked when I used for example the space bar. But the space bar always got stuck on the button to select the street (if i pressed it once and then the space bar, it was pressed another time). I fixed this with setting the navigation setting in the button to “none”, but after that, Unity crashed as well with the space bar as input.

I personally think that there is some strange interaction between my code and the input system, but I have no clue where.

I really hope someone can help me there

Ok, I fixed it, but I dont know how, I guess it were just some weird errors in my code