- Home /
how to access a specific instance of a script
hello. i have a script that a button uses to start a function on my gun script that buys ammo. problem is that i have multiple instances of my gunscript on the same camera so when i use sendmessage from the button to the camera it adds ammo only to one script. so i need to access a specific instance of the gunscript so it adds ammo to the weapon the player is using.
Answer by Fanttum · Mar 20, 2015 at 01:34 AM
Assign it from the inspector. By making a public variable and than dragging the script you need into it. or. Tag the instance you need and look up the instance by tag.
Your answer
![](https://koobas.hobune.stream/wayback/20220613190713im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
How do I get Single ammo reloading to work? 0 Answers
Gun script not working 3 Answers
FPS UI ammo display problem 0 Answers