I don't know what is wrong with my script.

using UnityEngine;
using System.Collections;

public class GunData : MonoBehaviour {

public float ROF; //changes rate of fire
public float dmg_amp; //modifies damage done by bullet
public float power; //changes muzzle velocity
public float AOE; //area of effect(blast radius) leave at 0 unless it is an explosive
public bool can_fire; //used to temporarily enable/disable weapons and to enforce ROF
public Rigidbody bulletpre; //defines prefab of projectile
public Transform barrel; //defines place for projectile to be chucked from

// Use this for initialization
void Start () {

}

void Update() {
if (Input.GetMouseButton(0))
Debug.Log(“Pressed left click.”);
}
}

This is a script in c# and it does not work. The variables are there for when I use it for gun controls, but I can’t get the mouse detection to work at the moment, please help as I am still new to programming and am not very good at it.

Looks good to me. Are you sure this script is attached to a gameobject in your scene? also, please use code tags.

Works fine, I just tested it. Needs to be attached to a gameobject in the scene, the script file itself must be called GunData.cs and it should work if you hit play and left click in your game view, not scene view. Are you getting any errors in your console?

I double checked that it was attached to a gameobject(the gun I made) and it still isn’t working, there are no errors, it simply isn’t responding; btw I will remember to put it in code tags the next time I put a script. The gun itself is paired under several other gameobjects in the hierarchy, could this cause it to fail? Also, I am using the free version of unity, I don’t know if this matters when scripting however.

Try Input.GetKey(“Fire1”); instead
And no, it doesn’t matter if the GameObject is a child of another GameObject. And if you are having a problem it is not related to the free version.

Narrow down your problem: Create a Debug.Log statement in you Start() method and see if it prints out, when you start the game. If it doesn’t, you’re script is somehow not enabled during runtime. This could be the case if any of the parent objects are set inactive. Create a new empty gameobject and attach your script there. Check for copy paste errors and see that all involved components are active.

Just a blind guess: When you are playing, are you sure, that your scene isn’t paused? Right next to the play arrow, there’s a pause symbol, that can be toggled before the scene starts and therefore, it never runs.

Ensure the gameobject the script is attached to is enabled?

Anyway, we can sit here and shoot in the dark with you, but it might be better if you exported the project as a unity package and let us take a look.

Ok, this may sound pretty weird but I tried putting a debug.log command in the start function and it didn’t work, but I tried using getkey anyway. At that point I started getting a load of errors(probably because I typed something wrong) but then I changed it back to getmousebuttondown and it worked perfectly! Than you for the help because I would never have tried that if I hadn’t asked here.