Terrain Footsteps Problem [SOLVED]

Hello,
I have a script for my player that checks what texture he is on to play a sound but
it dumps this error a ton in the console when i use the script, i attached it to my player

Here is where i got the script from, i just combined the two last scripts together, without any additional errors except below one : Terrain Footsteps in Unity (how to detect different textures) - John Leonard French

ArgumentException: Inlavid argument for GetAlphaMaps
UnityEngine.TerrainData.GetAlphaMaps (System.Int32 x, System.Int32 y, System.Int32 width, System.Int32 height)

Here is the code :

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class CheckTerrainTexture : MonoBehaviour {

public Transform playerTransform;
public Terrain t;

public int posX;
public int posZ;
public float[] textureValues;

public AudioSource source;

public AudioClip[] stoneClips;
public AudioClip[] dirtClips;
public AudioClip[] sandClips;
public AudioClip[] grassClips;

AudioClip previousClip;

void Start ()
  {
    t = Terrain.activeTerrain;
    playerTransform = gameObject.transform;
  }

void Update()
  {
    // For better performance, move this out of update
    // and only call it when you need a footstep.
    GetTerrainTexture();
  }

public void GetTerrainTexture()
  {
    ConvertPosition(playerTransform.position);
    CheckTexture();
  }

void ConvertPosition(Vector3 playerPosition)
  {
    Vector3 terrainPosition = playerPosition - t.transform.position;

    Vector3 mapPosition = new Vector3
    (terrainPosition.x / t.terrainData.size.x, 0,
    terrainPosition.z / t.terrainData.size.z);

    float xCoord = mapPosition.x * t.terrainData.alphamapWidth;
    float zCoord = mapPosition.z * t.terrainData.alphamapHeight;

    posX = (int)xCoord;
    posZ = (int)zCoord;
  }

void CheckTexture()
  {
    float[,,] aMap = t.terrainData.GetAlphamaps (posX, posZ, 1, 1);
    textureValues[0] = aMap[0,0,0];
    textureValues[1] = aMap[0,0,1];
    textureValues[2] = aMap[0,0,2];
    textureValues[3] = aMap[0,0,3];
  }
  public void PlayFootstep()
{ 
  GetTerrainTexture();

  if (textureValues[0] > 0)
  {
    source.PlayOneShot(GetClip(stoneClips), textureValues[0]);
  }
  if (textureValues[1] > 0)
  {
    source.PlayOneShot(GetClip(dirtClips), textureValues[1]);
  }
  if (textureValues[2] > 0)
  {
    source.PlayOneShot(GetClip(dirtClips), textureValues[2]);
  }
  if (textureValues[3] > 0)
  {
    source.PlayOneShot(GetClip(dirtClips), textureValues[3]);
  }
}

AudioClip GetClip(AudioClip[] clipArray)
  {
    int attempts = 3;
    AudioClip selectedClip =
    clipArray[Random.Range(0, clipArray.Length - 1)];

    while (selectedClip == previousClip && attempts > 0)
      {
        selectedClip =
        clipArray[Random.Range(0, clipArray.Length - 1)];
      
        attempts--;
      }

    previousClip = selectedClip;
    return selectedClip;

  }
}

Managed to narrow down the issue its from like 59 but everything is an integer inside

I fixed the issue, it was just the problem of me not being on the terrain