This will be incredibly dependent on the league you are in, so the best thing to do is ask the refs in your league. However, my guess is that they'd follow similar guidelines as the NBA or NCAA, so I'll look at both of those below.
First and foremost, the refs should have called a technical on your team regardless of whether you made the shot.
For NCAA, according to Wikipedia:
[C]ollegiate basketball (both men's and women's) limit teams to five players on the court at any one time. A team with more than five in play at once is assessed a technical foul for Too Many Players on the Court.
For NCAA rules, the technical would have resulted in "two free throws... be[ing] awarded to any member of the offended team" (page 103). I can't find anything specific on whether you'd keep the points in the NCAA, but fortunately the NBA is much clearer.
In the NBA rules, section VII.E addresses too many men on field specifically (emphasis mine):
If the ball is put into play and remains in play with one team having six or more players on the court, a non-unsportsmanlike technical foul will be assessed on the team with too many players. Immediately following the free throw awarded for the technical foul, the team with the correct number of players will instruct the Crew Chief to:
resume play from the point in time when the technical foul was assessed, under the
same conditions as would have prevailed had there been no error with a throw-in,
jump ball or foul shot, as appropriate.
nullify all play that occurred from the point in time when the ball was put into play
with one team having six or more players on the court and ending when the technical
foul was assessed, and reset the game and shot clock to the point in time when the
ball was put into play, and if the ball was put into play by:
a throw-in, the ball shall be returned to the original throw-in spot with all privileges
remaining, if any, or
a missed free throw that remained in play, a jump ball shall be held at center
court between any two players in the game, or
a jump ball, the ball shall be returned to the original jump ball spot and a jump
ball held with the same two players.
EXCEPTION: Acts of unsportsmanlike conduct and all flagrant fouls, and points scored
from any resulting free throws, shall not be nullified.
(2) Other errors involving the wrong number of players at the start of play, four or less,
are not correctable. Following the technical foul, play shall resume from the point-of-interruption.
Under NBA rules, if you had made the shot, the offended team probably would have opted for option 2 and nullified all game play that occurred when your team had 6 players on the court, including your basket.
Edit:
The NCAA rulebook, Rule 10, Section 2 (Administrative Technical Fouls), Article 6:
Art. 6. A team shall not have more than five players legally on the playing court
to participate after the ball becomes live.
PENALTY: (Art. 6) Penalized when the violation occurs after the ball
becomes live. Two free throws awarded to the offended team.
The ball shall be put back in play at the point of interruption.
Since the Point of Interruption is when "a stoppage in play occurs," I would interpret this to mean that you would keep the points if you made the shot before the technical was called.