Enumerator problem

I’ve got a JS Script

enum Attachments {Ironsight  = 0, Acog = 1, Scope = 2}
var currentAttachment = Attachments.Ironsight;

and i want to change the currentAttachment from another JS like:

transform.GetComponent(WeaponScript).currentAttachment = transform.GetComponent(WeaponScript).Attachments.Ironsight;

I don’t see a question in there, or any posting of what specific error you’re seeing, so I’m going to guess: it doesn’t like the way you’re defining transform.GetComponent(WeaponScript).Attachments.Ironsight;

In this case, you want to use the name Attachments, rather than a specific instance of attachments. So what you want is something like:

... = WeaponScript.Attachments.Ironsight;