RhythmService documentation

Methods

void :SetSound(sound, keepKeys, startStopwatchOnPlay)

Stores a sound in the module.

  • sound (instance) - A Sound instance stored in the module.
  • keepKeys (boolean) - If true, the keys defined by :SetKeys or :AddKey will not be removed.
  • startStopwatchOnPlay (boolean) - If true, :StartStopwatch will be fired when the sound is :Play()'d

void :AddKey(timePosition, index)

Adds a key to the table.

  • timePosition (number) - A position in the sound
  • index (number, optional) - An index in the keys table to replace

void :SetKeys(keys)

Like :AddKey, but bulk-adds keys to the table.

  • keys (table) - A table of time positions

Example:

RhythmService:SetKeys({0.2, 1, 5})

void :RemoveKey(index)

Removes a key from the table

  • index (number) - Index of the key

void :ToggleKey(disable, index, keepPosition)

Enables a key. This method only works when the stopwatch is active.

  • disable (boolean) - If true, the next key will be a priority. If there is no next key, :Stop stopwatch() will fire.
  • index (number, optional) - The key in question.
  • keepPosition (boolean, optional) - If true, the current key will not shift.

void :ResetKeys()

Reactivates all keys.


table :CheckRhythm()

Returns a table with accuracy data based on the current key.

The table includes the following keys:

  • Rating (number) - A rating based on the tolerance level closest to the hit time. This is nil if the hit time isn’t in any tolerance range.
  • GoalTime (number) - The perfect time in seconds
  • HitTime (number) - The actual time in seconds

void :StopStopwatch()

Stops the stopwatch.


void :StartStopwatch()

Run :ResetKeys and (re-)starts the stopwatch.


Events

.OnIdle()

Fires when CheckRhythm() isn’t called and a key passes while the stopwatch is active.


GitHub version: API documentation · Beastslash/Roblox-RhythmService Wiki · GitHub

1 Like