@@ -11,11 +11,7 @@ local RhythmService = {
11
11
local Song = {Sound = nil , Keys = {}, KeyPosition = 1 , StopwatchEvent = nil };
12
12
local Events = {};
13
13
14
- function RhythmService :SetSound (sound , keepKeys , startStopwatchOnPlay )
15
- assert (sound and sound :IsA (" Sound" ), " A sound instance must be the first argument" );
16
- assert (not keepKeys or typeof (keepKeys ) == " boolean" , " keepKeys must be a boolean or nil" );
17
- assert (not startStopwatchOnPlay or typeof (startStopwatchOnPlay ) == " boolean" , " startStopwatchOnPlay must be a boolean or nil" );
18
-
14
+ function RhythmService :SetSound (sound : Sound , keepKeys : boolean ? , startStopwatchOnPlay : boolean ? )
19
15
-- Set sound and remove keys if necessary
20
16
Song .Sound = sound ;
21
17
if not keepKeys then
@@ -31,10 +27,8 @@ function RhythmService:SetSound(sound, keepKeys, startStopwatchOnPlay)
31
27
end ;
32
28
end ;
33
29
34
- function RhythmService :AddKey (timePosition , index )
30
+ function RhythmService :AddKey (timePosition : number , index : number ? )
35
31
assert (Song .Sound , " A sound instance must be defined before adding a key" );
36
- assert (timePosition and tonumber (timePosition ), " A time position must be given to add a key" );
37
- assert (not index or tonumber (index ), " index must be a number or nil" );
38
32
39
33
-- Add key
40
34
local Key = {timePosition , 1 };
@@ -45,9 +39,7 @@ function RhythmService:AddKey(timePosition, index)
45
39
end ;
46
40
end ;
47
41
48
- function RhythmService :SetKeys (keys )
49
- assert (not keys or typeof (keys ) == " table" , " keys must be a table or nil" )
50
-
42
+ function RhythmService :SetKeys (keys : { number }? )
51
43
-- Set keys
52
44
Song .Keys = {};
53
45
if keys then
@@ -57,8 +49,7 @@ function RhythmService:SetKeys(keys)
57
49
end ;
58
50
end ;
59
51
60
- function RhythmService :RemoveKey (index )
61
- assert (not index or tonumber (index ), " index must be a number" );
52
+ function RhythmService :RemoveKey (index : number )
62
53
table.remove (Song .Keys , index );
63
54
end ;
64
55
@@ -87,11 +78,7 @@ function RhythmService:CheckRhythm()
87
78
return Result ;
88
79
end ;
89
80
90
- function RhythmService :ToggleKey (disable , index , keepPosition )
91
- assert (not disable or typeof (disable ) == " boolean" , " disable must be a boolean or nil" );
92
- assert (not index or tonumber (index ), " Index must be a number or nil" );
93
- assert (not keepPosition or typeof (disable ) == " boolean" , " Index must be a number or nil" );
94
-
81
+ function RhythmService :ToggleKey (disable : boolean ? , index : number ? , keepPosition : number ? )
95
82
-- Toggle key and shift position
96
83
Song .Keys [Song .KeyPosition or index ][2 ] = (disable and 0 ) or 1 ;
97
84
if not keepPosition and # Song .Keys >= Song .KeyPosition + 1 then
0 commit comments