@@ -46,11 +46,14 @@ function RhythmService:AddKey(timePosition, index)
46
46
end ;
47
47
48
48
function RhythmService :SetKeys (keys )
49
- assert (typeof (keys ) == " table" , " keys must be a table" )
49
+ assert (not keys or typeof (keys ) == " table" , " keys must be a table or nil " )
50
50
51
51
-- Set keys
52
- for _ , timePosition in ipairs (keys ) do
53
- table.insert (Song .Keys , {timePosition , 1 })
52
+ Song .Keys = {};
53
+ if keys then
54
+ for _ , timePosition in ipairs (keys ) do
55
+ table.insert (Song .Keys , {timePosition , 1 })
56
+ end ;
54
57
end ;
55
58
end ;
56
59
@@ -60,6 +63,7 @@ function RhythmService:RemoveKey(index)
60
63
end ;
61
64
62
65
function RhythmService :CheckRhythm ()
66
+ assert (# Song .Keys > 0 , " There has to be at least one key!" );
63
67
assert (Song .StopwatchEvent and Song .StopwatchEvent .Connected , " The stopwatch hasn't started!" );
64
68
65
69
local SongPosition = Song .Sound .TimePosition ;
@@ -113,8 +117,11 @@ end;
113
117
114
118
function RhythmService :StartStopwatch ()
115
119
assert (Song .Sound , " A sound hasn't been defined!" );
120
+ assert (# Song .Keys > 0 , " There has to be at least one key!" );
121
+
116
122
RhythmService :StopStopwatch ();
117
123
RhythmService :ResetKeys ();
124
+ Song .KeyPosition = 1 ;
118
125
119
126
-- Add a new SW
120
127
Song .StopwatchEvent = RunService .Heartbeat :Connect (function ()
0 commit comments