Can't add script component

I’m trying to do this :

They won’t give out the script, so I retyped the whole thing using wordpad. I don’t know anything about scripting and maybe I got some errors in there. I don’t know how to check that. The problem is I’m getting an error when adding the script to my terrain : “can’t add script component because the script class cannot be found…”
The name of the script is the same (PaintTerrain) so that can’t be the problem.

Here’s the script :

using UnityEngine;
using System.Collections;

public class PaintTerrain : MonoBehaviour 

{
    
   [System.serializable]
   public class SplatHeights
   {
     public int textureIndex;
     public int startingHeight;
   }

  public SplatHeights[] splatHeights;

  void Start() 
  {

TerrainData terrainData = Terrain.activeTerrain.TerrainData;
float[, ,] splatmapData = new float[terrainData.alphamapWidth,
						terrainData.alphamapHeight,
						terrainData.alphamapLayers];

 for (int y = 0; y < terrainData.alphamapHeight; y++)
 {
   for (int x = 0; x < terrainData.alphamapWidth; x++)
   {
   float terrainHeight = terrainData.GetHeight(x,y);
   float[] splat = new float[splatHeights.Length];
   for(int i = 0; i < splatHeights.Length; i++)

     {
      if(terrainHeight >= splatHeights*.startingHeight)*

splat = 1;
}

for(int j = 0; j < splatHeights.Length; j++)
{
splatmapData[x, y, j] = splat[j];
}

}
}

terrainData.SetAlphamaps(0, 0, splatmapData);

}
}


The names are case sensitive ‘paintTerrain’ isn’t
the same as ‘PaintTerrain’. The script’s name and
code needs to have the same ‘PaintTerrain’ name.


You have a error at Ln 8


[System.serializable]

to


[System.Serializable]

You have an error at Ln 20


TerrainData terrainData = Terrain.activeTerrain.TerrainData;

to


TerrainData terrainData = Terrain.activeTerrain.terrainData;

Also, I would suggest downloading something like VS Code
and Learn With Unity. Using WordPad is just asking for a bad
time. VS Code Setup

You also have a error on Ln.34


   if(terrainHeight >= splatHeights*.startingHeight)*

splat = 1;
----------
Should be:
----------
if(terrainHeight >= splatHeights*.startingHeight)*
{
splat = 1;
}

@KiTS0
Thanks for your answer.

I made the modifications but it still isn’t working. (same message)
The file name is the same (PaintTerrain).
I installed VS Code, not sure what to do with it. Can it tell me what’s wrong ?

Thanks for the tutorial. I’m using Unity to create a world to use as backgrounds,
I’m not making a game. So I’ll have to skip some of them.