Gun Game Results Fix

The Gun Game starter game has a known issue in which the table of results is not sorted, therefore the results will often display incorrectly (as a draw, or showing the wrong user as the winner). There is a simple fix for this, which is to edit the script called “gunGameScript” and insert this line into line 60:

table.sort(results.userEntries, function(u1, u2) return u1.rank < u2.rank end)

Which should result in the “GetResults” function of the “gunGameScript” looking like this:

function GunGameScript:GetResults(results)
	
	Print("GunGameScript: Getting results")

	-- rank 1 is winner, everyone else is 2
	results.userEntries = {}
	GetWorld():ForEachUser(
		function(userEntity)
			table.insert(results.userEntries, {
				user = userEntity, 
				score = userEntity:FindScriptProperty("score") or 0,
				rank = userEntity == self.winner and 1 or 2
			})
		end
	)
	table.sort(results.userEntries, function(u1, u2) return u1.rank < u2.rank end)
end
1 Like