Global_position isn't global

I’m on Godot 4.2.1 (Linux Mint) right now, and have a player scene and a bullet scene.
Now, everything was working fine. I click my mouse, and my player shoots bullets in the direction of my mouse. I was working on other parts, and didn’t test the shooting in a while. But then the vector at which the bullets were shot was magically off. I messed around mainly with physics and display settings. After resetting the display settings, it still didn’t work and now I’m left incredibly confused.
I believe the culprit is global_position. In my player scene, I have a Marker2D named Gun. In my player script _input() waits for an action named shoot. Now, when I print the global_positionof the event and start moving my player, the coordinate stays the same, but when I print the global coordinate of Gun in _physics_process() and start moving the player, the coordinate moves with it! In fact, I believe it’s just the local coordinate.
Here’s my code:

func _physics_process(delta):

And here’s the output:

Here’s my code for the event:

func _input(event):
	if event.is_action_pressed("shoot"):

And here’s the output too (I’m spamming the mouse so the coordinates get updated)

I am confused.
Please help.

Also here’s my player scene:

I read your post again. Everything works correctly, the weapon is assigned to the player and its coordinate depends on the player’s coordinate. The local coordinate of the gun remains unchanged - that is, relative to the player, it can only move along the “orbit” near the player and that’s all, and the global coordinate shows the position of the gun in the main node.

Inside _input you can get the global position of where you clicked with get_global_mouse_position(). No idea what’s the deal with event.global_position…

This part is working correctly

func _physics_process(delta):

About the event, I’m not sure. If you need to get the mouse coordinates globally, I would use the built-in get_global_mouse_position() function

Please note that the word “global” is ambiguous.

See for more detailed discussion: Clarify what "global" means in the context of mouse position in different coordinate systems · Issue #3866 · godotengine/godot-proposals · GitHub

Within _input the event.global_position is in viewport coordinates.
%Gun.global_position is in canvas layer coordinates.

I assume, that you are using a Camera2D, so it is likely, that canvas layer coordinates are not identical to viewport coordinates.

You can find an introduction into the difference of these two coordinate systems and conversion between them in the docs: Viewport and canvas transforms — Godot Engine (stable) documentation in English (for a more detailed description, you can also look into 2D coordinate systems and 2D transforms — Godot Engine (stable) documentation in English)