Selective sensing and removal of toxic heavy metals from water are highly essential since their presence poses significant health and environmental hazards. Herein, we designed and synthesized a novel fluorescent nonconjugated organic polymer by strategically incorporating two key functional groups, namely, a dansyl fluorophore and dithiocarbamate (DTC). Different characterization techniques, including 1H nuclear magnetic resonance (NMR), scanning electron microscopy (SEM), X-ray diffraction (XRD), energy-dispersive X-ray analysis (EDAX), Fourier transform infrared (FTIR), and fluorescence spectroscopy, were performed to understand its structure and material properties. The quantum yield of 4.72% and its solid-state fluorescence indicate that it has potential for various applications in several technological and scientific domains. In this study, we investigated a specific application involving the detection and elimination of heavy metals from water. Interestingly, the presence of dansyl and DTC moieties demonstrated remarkable selectivity toward Cu2+, Co2+, Ni2+, Fe3+, and Fe2+ sensing, displaying distinct color changes specific to each metal. Cu2+ resulted in a yellow color, Co2+ showed a green color, Ni2+ displayed a pale yellowish-green color, and Fe2+/Fe3+ exhibited a brown color. The LOD (limit of detection) for each metal was obtained in the nanomolar range by using a fluorescence spectrometer and the micromolar range from UV-visible spectra: 13.27 nM and 0.518 μM for Cu2+, 8.27 nM and 0.581 μM for Co2+, 14.36 nM and 0.140 μM for Ni2+, 14.95 nM and 0.174 μM for Fe2+, and 15.54 nM and 0.33 μM for Fe3+. Moreover, the DTC functionality on its backbone facilitates effective interaction with the aforementioned heavy metals, subsequently removing them from water (except Fe2+ and Fe3+), validating its dual functionality as both an indicator and a purifier for heavy metals in water. The polymer exhibited a maximum adsorption capacity of 192.30 mg/g for Cu2+, 159.74 mg/g for Co2+, and 181.81 mg/g for Ni2+. Furthermore, this approach exhibits versatility in crafting fluorescent polymers with adjustable attributes that are suitable for a wide range of applications.