You cannot use this lens as an automatic lens on a D3500.
The Nikkor 50mm f1.8 D lenses require a specific version of the Nikon F mount that is not implemented fully on the D3500.
To autofocus it requires a camera with a lens motor in the body, which the D3500 does not have. You require Nikon lenses marked as "G AF-S" or third party lenses with focus motors in the lens itself for full automatic operation. The Nikon G AF-P lenses also apparently work fully.
According to the manual for the D3500 (always a good place to start !) D type lenses can only be used in M mode - that is using full manual exposure - no automatic controls at all.