How to reference field of another entity's script from another script

these are the codes to the combat system:
The codes given to the player: Combat_Part_1.js

The codes given to the target: Combat_Part_2.js

As of now, the damage variable in Combat_Part_1 does nothing. It works by changing its value based on the amount of damage each weapon does. It should also work by applying that amount of damage to the target’s health in Combat_Part_2. In line 17, of Combat_Part_2, how would I change the number 25 with the value of the damage variable?

If Combat_Part_1 is set on Entity with collision component, which end up colliding, then you better to store damage variable as part of that script body. Have field value, in Combat_Part_1 in initialize add this.damage = 25, then modify that value.
Currently in your Combat_Part_1 you defined damage as global variable, no good.

Then in Combat_Part_2, in collision callback, you can get damage of a collider: result.other.script.Combat_Part_1.damage.
result.other - points to entity that collided with you. And to access its script value, you have to reference script by its name.

Your management of items, is somewhat limiting too. I would have separate entities per each axe, and have special script that would be attached to axe, defining it as wearable item, and build logic around such concept.

Please name your topic in a bit more informative way, rather than generic, to help community to navigate around.

where do I add the parts “result.other.script.Combat_Part_1.damage”, and “result.other”?

In Combat_Part_2.js you already referencing result.other on line 16.
And on line 17 is where you would change damage as you’ve asked in question above.

do I add it to the code already there or do I move the codes on line 16 and 17 down and then add the code?

what would the scripts look like in general.
I have only had about 3-4 weeks of coding experience.

I think you better to experiment and play, learn as you go.

That method does not always work for me. I have tried that method on previous attempts to do other projects such as building some electric circuit. But from my experience it can take me years to finish doing it that way. In my case trial and error only sets me up for a long wait, and barely anything gets accomplished. In all the time I have worked with trial and error in playcanvas, I have only gotten enough in the game to where the player can move around and look around. Perhaps the player can have some interactions with other objects.

I tend to learn things better through examples. After all, most of the code I have already created were borrowed form other codes that I did understand, then the codes were modified to fit my own purposes. The part where the target takes damage when struck, was based of a code where when the entity is struck in makes a noise. I just had it modified to where there is a number called “health”, that loses value when the entity is struck, and once it reaches 0, the entity is destroyed.