Correct way to connect MOSFET's source with the circuit's ground
Try something like this instead. This circuit should not release any magic smoke.
I don't usually use TinkerCAD but thought I'd check it out... Code section leaves a lot to be desired. I wasn't able to figure out how to get the pinMode() assignment to allow the internal pull-up so I had to add one to the circuit.



simulate this circuit &ndash; Schematic created using CircuitLab

Link to TinkerCAD Circuit