Referencing a script from another script?
Hello, I’ve been working on a multiplayer game recently , i’m starting to implement damage and health system but i’m facing a small issue, what i’m doing is i’m giving each gun in my player inventory a damage int, so in order to use this damage variable i’m referencing the gun using Gameobject.findObjectOfType(gun).getComponent<gun> on the bullet prefab everything works fine, until the other player joins, the script will find 2 or multiple gameObjects of type gun which will mix up the variables, for example one player will be holding a pistol with 20 Damage while the other player holding a shotgun with 50 damage the script will be confused as there is 2 gun scrips with different variables
1-note that I’m instantiating the bullet so i’t can’t be assigned directly in the inspector
2-I don’t want to use raycasts, i’m good with projectiles
if you managed to solve this, thank you, you’re a genius and you saved me hours of work.