From 05858a4f6c1132dcf0c071f418109f686636517b Mon Sep 17 00:00:00 2001
From: Cameron Taylor <cameron.taylor.ninja@gmail.com>
Date: Mon, 11 Jul 2022 15:04:41 -0400
Subject: [PATCH] crash fix when pressing before loop

---
 source/funkin/LatencyState.hx | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/source/funkin/LatencyState.hx b/source/funkin/LatencyState.hx
index 6de472584..79885d1bd 100644
--- a/source/funkin/LatencyState.hx
+++ b/source/funkin/LatencyState.hx
@@ -125,7 +125,7 @@ class LatencyState extends MusicBeatSubstate
 
 		if (FlxG.keys.justPressed.X)
 		{
-			var closestBeat:Int = Math.round(Conductor.songPosition / Conductor.crochet);
+			var closestBeat:Int = Math.round(Conductor.songPosition / Conductor.crochet) % diffGrp.members.length;
 			var getDiff:Float = Conductor.songPosition - (closestBeat * Conductor.crochet);
 			getDiff -= Conductor.visualOffset;