The gang carried a handgun, a crowbar and a machete as they burst into the Kirkcaldy home of Dwayne Kinner, who was with his cousin Nicholas Roberts.
James Mackie, 30, Derek Finlay, 31, Gordon Ellis, 24, and Scott Smith, 23, raided the flat on 8 January 2015.
A stolen phone with a tracking app took the police to the gang.
They also made off with a haul of Â£2,500.
The High Court in Edinburgh heard that the victims believed they were going to be shot after the gun was pointed at their heads and another robber threatened he was going to cut their fingers off.
The gun, which was discovered to be an air pistol, was later found behind a kickboard in a kitchen at a house in Glenrothes, which Finlay had previously had access to.
Advocate Ashley Edwards QC said it had the appearance of a firearm.
Mackie, from Kirkcaldy, Ellis, from Cardenden, Finlay, a prisoner and Smith, from Cardenden, all pleaded guilty to assaulting and robbing the victims.
Judge Michael O'Grady QC deferred sentence for the preparation of background reports and all four were remanded in custody.
Four thieves who forced their way into a Fife flat and held two men at gunpoint while they stole money and valuables have admitted the raid.