The eight-game homestand the Lakers played over three weeks because of the weeklong All-Star break was an opportunity for them to develop a connectivity that would push them in the right direction.

Instead, the Lakers floundered in those games at Crypto.com Arena, playing .500 basketball, punctuated by a 110-109 loss to the Orlando Magic on Tuesday night when Luka Doncic passed up a wide-open three-pointer and threw the ball to LeBron James, who missed a hurried buzzer-beater.

The Lakers (34-23) have not been a great team at home, their record now 16-12 in Los Angeles. And after losing a second straight game at home, they fell to sixth place in the competitive Western Conference.

After the game, James was asked why the Lakers haven’t been so good at home.

“I don’t know,” said James, who finished with 21 points on eight-for-13 shooting, six rebounds and four assists. “Just haven’t been a good home team.”

The Lakers opened the homestand with wins over Philadelphia and Golden State, lost back-to-back games to Oklahoma City and San Antonio, beat Dallas and the Clippers and then finished it with losses to Boston and Orlando.

Coach JJ Redick was asked why his team hasn’t been better at home.

“We’re a work in progress,” Redick said.

The lead went back and forth most of the fourth quarter, each play more important than the previous one, each moment more intense, each possession more meaningful for both teams.

When Rui Hachimura drilled a three-pointer from the corner off a pass from Doncic for a 106-103 lead with 2:14 left, the Lakers looked to be in pretty good shape.

But Magic star Paolo Banchero scored, giving him a game-high 36 points, and was fouled by Deandre Ayton. Banchero missed the free throw, leaving the Lakers ahead 106-105 with 1:18 left.

James went to work in the post over the smaller Anthony Black, drawing a foul. But James made just one of two free throws for a 107-105 Lakers lead

Magic guard Desmond Bane (22 points) answered with a three-pointer for a 108-107 lead that forced the Lakers to call a timeout with 34.6 seconds left.

Hachimura missed a three, but the Lakers retained possession and on the ensuing inbounds play, Doncic found James cutting down the lane for a dunk and a 109-108 lead.

Banchero missed a jumper, but Wendell Carter Jr. (20 points) grabbed the rebound and scored for a 110-109 Magic lead with 6.7 seconds left. The Magic finished with 13 offensive rebounds.

Then came the moment of truth for the Lakers.

Out of a timeout, Doncic got free beyond the three-point line, but the Magic sent Black and Banchero at him.

Doncic was not having one of his better shooting nights, having missed 16 of 24 shots, eight of 10 three-pointers and even five of nine free throws en route to 22 points.

Luka Doncic and Orlando coach Jamahl Mosley talk during the first half.

Luka Doncic and Orlando coach Jamahl Mosley talk during the first half.

(Caroline Brehman / Associated Press)

So instead of taking the shot, Doncic passed to James.

“I just saw him open and I didn’t want to lose the ball,” Doncic said. “We didn’t have timeouts. … I shouldn’t have picked up the ball. I should have attacked. … That’s on me.”

Perhaps, Doncic was asked, he didn’t take the clutch shot because he was not on top of his game at that moment.

“Maybe a little bit,” Doncic said. “I think I thought it was more time. It was, what, 6.7 seconds? It was enough time to get a better look, try to drive the ball.”

When James got the ball, 6-foot-10 Magic center Jonathan Isaac recovered and played good defense, forcing James into taking an off-balance turnaround three.

“We executed. Like I said, I’m not sure,” James said. “ Obviously, you have to ask Luka what he saw on that. But I thought he had a good look and it looked like he kinda just lost his balance, you know. Didn’t have a rhythm with the ball, whatever the case may be. And it kinda allowed them to get back in front of him. And I was kind of off-balance when he gave it to me. I thought he had a great look.”

The Lakers got a good game out of Ayton, who had 21 points and 13 rebounds for his first double-double since Jan. 30. Ayton was aggressive in going eight for 11 from the field and five for five from the free-throw line.

“It’s a bit upsetting,” Ayton said about losing games at home. “…We still got a lot of chances to just get in a good position as we can. Did feel weird in the homestand, you know, just being 4-4. It was tough losses and played against some really good teams. But, you know, we play every other day. So, just get back in the lab and just get ready for the next game.”

The Lakers have 25 games remaining in the regular season, 13 at home.