Using Input to play AnimationClip not working in Standalone / Web

Hello. I came up with a problem I cannot seem to figure out on myself no matter how hard I try.

I have a simple script which uses button/mouse input to run an AnimationClip. It works flawlessly in the editor and gives me 0 errors in the console, but once I build the game for Standalone or Web platform, nothing happens on the input. The animation works without the script when set to play automatically, so I think the problem is with the script, but I just can’t figure out what’s wrong with it.

Here’s the script:

#pragma strict

var OpenSound : AudioClip;

function Update()
{
if (Input.GetButton("Fire1")) {
audio.PlayOneShot(OpenSound);
animation.Play("Hitweapon1");


}}

PS. The AnimationClip is marked as Legacy since it doesn’t work without doing so.
PPS. I’ve tried modifying the script using “GetButtonDown” instead of “GetButton”, using a specific KeyCode instead of “Fire1”, using a variable for the AnimationClip, none of these make a difference, it does not work once I build it for Standalone or Web.

Oh.Em.Gee… I spent over 4 hours altogether trying to solve this problem. Then it all came down to being something so simple as not having an audio clip assigned to the OpenSound variable.

I removed the variable since I don’t have an appropriate audio file available atm, also removed the “audio.PlayOneShot(OpenSound);” and it started kicking like it never happened.

It saddens me though, that Unity wouldn’t give me an error for not having the audio file there, it made me think it’s not a problem if the slot is left unoccupied.

I hope if someone ever comes up with the same problem they can find salvation here… I feel ridicilous for being stuck for so many hours with something so simple.