Blueface's allegedly opening fire on a vehicle -- and subsequently getting arrested for attempted murder -- was the end result of a joke falling flat and sparking a strip club fight.
According to legal docs, obtained by TMZ, Blueface and his crew were at Euphoric Gentlemen's Club in Vegas on October 8 ... and the alleged victim supposedly made a joke about the rapper talking with "some females in a cheap vehicle."
Cops say the joke set off members of Blueface's crew, who allegedly hit the man "multiple times."
The docs say the man then attempted to leave in his truck, and told cops Blueface's crew might have thought he was "going for a gun" ... leading to Blueface allegedly firing shots at the man's truck as he fled.
Cops say there were multiple bullet marks on the truck, and its owner suffered what appeared to be a "bullet graze wound" on his left hand.
As we reported, video obtained by TMZ showed the truck suddenly pulling up to the rapper and his crew in the club's parking lot -- and it appears to show Blueface pulling out a weapon and firing it in the direction of the truck.