The only thing that comes to mind is maybe you have accidentally got a different gameobject with the player tag and it’s automatically raycasting to that rather than your player gameobject. Did you by any chance do some duplicating with these capsules? That copies everything including your what tag they’re set to, that would be the first thing I’d check. You should also see that the debug.drawray isn’t leading you astray and pay more attention to the actual result of your code through the debug.log, his “Hit” even initiating when the game is started?
Physics.Raycast(gunPosition.transform.position, player.transform.position, out Hit)
IIRC most if not all raycast method overloads want an origin position and a direction.
Here it seems like you gave two positions, as if those were end points of a line. You’ll most likely want a direction from bot to player (player.position - bot.position).
Then optionally normalize that and use it as your shooting direction, and start/origin point of ray is the bot position.
Now you’ve pointed that out @eses yes it seems like this is more just a general maths problem than something a raycast should be used for unless @kevtv278 is trying to do something specific but we’ll let them elaborate on that.