Can´t see the bug in my script

I have this Tilesystem script you can but on yea small planes, think tower defece, and i cant get it too work i have tried some diffrent things but none of them have been succesfull here is the code.
The script is supose to spawn a tower when you left click the plane and should only spawn on that plane of the many diffrent prefab of the same plane.

using UnityEngine;
using System.Collections;

public class MyTileSystem : MonoBehaviour {
	private bool On = true;
	public GameObject ObjTower;
	
	// Use this for initialization
	void Start () {
	
	}
	
	// Update is called once per frame
	void Update () 
	{
		    if(Input.GetMouseButton (0))
    {
        RaycastHit hit;
        Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
       
        if(Physics.Raycast (ray, out hit))
        {
            MyTileSystem tile = hit.collider.GetComponent<MyTileSystem>();
           
            if(tile != null)
            {
                tile.SpawnTower(); 
            }
        }
    }
}    
	
	
	public void SpawnTower()
    {
        if(On)
        {
            On = false;
            GameObject tower;
            tower = Instantiate(ObjTower, transform.position, transform.rotation)as GameObject;
        }
    }
}

What problem are you having? “Doesn’t work” does not help us problem-solve at all.

Try the OnMouseDown / OnMouseDownAsButton function instead.

oh sorry, the problem is when i click one of the planes nothing happens, nothing spawns, it accept that i send out a raycast but it cant find the plane i have done some debugging and that is where the chain snaps, still dont know how to fix it.

are you sure there’s a collider attached to each tile?

Yes there is a Mesh collider

i would double check your project settings for things like Time.timeScale (make sure its greater than 0) and your physics settings for how often it polls. I’ve noticed occasionally that my input breaks when my timeScale somehow becomes 0. I can’t actually explain that but its happened to me before.

Additionally i’ve noticed that Physics.Raycast will miss objects that have 0 depth in them and on other occasions it hits them just fine. However i’ve never seen an issue with anything greater than 0.0001 in depth.

Finally MeshColliders have given me the biggest trouble in unexplained behaviour. Box and Sphere colliders is where its at for me.

Ok I have tried the script on my friends pc and it works thank you alot for the help