I was using a basic movement script for a characterbody 3d and I tried to add the mouse capture code. It seemed fine in the script editor but when I launched the game it gave errors in that line for some reason. I checked the code and it was alright but it just kept happening. I restarted the editor and it worked fine again and the bug was fixed.
It was just shown in red like how it shows when the code is written wrong. The code was Input.set_mouse_mode(MOUSE_MODE_CAPTURED).
I might have written it wrong here but it was right in godot