Return statement in class function (Javascript)

I tried to translate a script from C# to UnityScript (javascript?).
The C# code works perfect… but my “translation” throws this error:

“Cannot Convert ‘PlayerDataClass’ to ‘void’”

Surely I made something wrong in the “translation” and I don’t know what it is…

The original code in C#:

public class PlayerDataClass {
   public int networkPlayer;
   public string playerName;
   public int playerScore;
   public string playerTeam;

   public PlayerDataClass Constructor() {
      PlayerDataClass capture = new PlayerDataClass();
      capture.networkPlayer = networkPlayer;
      capture.playerName = playerName;
      capture.playerScore = playerSocre;
      capture.playerTeam = playerTeam;
      return capture;
   }
}

My UnityScript translation:

 class PlayerDataClass {
 var networkPlayer : int;
 var playerName : String;
 var playerScore : int;
 var playerTeam : String;
 
    function PlayerDataClass() {
       var capture : PlayerDataClass = new PlayerDataClass();
       capture.networkPlayer = networkPlayer;
       capture.playerName = playerName;
       capture.playerScore = playerScore;
       capture.playerTeam = playerTeam;
       return capture;
    }
 }

“return capture” is where the console tells me it’s wrong.

Thanks in advance to anyone willing to help me.

The constructor in a class can’t return anything. The correct translation of

public PlayerDataClass Constructor() {

is

function Constructor() : PlayerDataClass {

In this case you have a function called “Constructor”, but it’s not actually a constructor. I’d recommend creating a proper constructor instead.