hello i am creating a rhythm game, and i have ran into a problem, i am trying to make the note frames according to the musics beat but for some reason the notes are moving really fast
–video
–Script that handles the spawning of the note frame
function sync:OnStart()
self.audio:Play()
self.secPerBeat = 60.0 / self.bpm
self.dspSongTime = self.audio.TimePosition
while true do
print(self.audio.PlaybackLoudness)
wait(self.secPerBeat/self.audio.PlaybackLoudness)
self:OnCreateNotes(self.audio.PlaybackLoudness)
end
end
—Scripts for creating the notes
function sync:OnCreateNotes(audio)
local last = tick()
local time = 0
self.eventFireTime = 10
if self.eventFireTime <= self.songBPM.Value then
time = last + self.songBPM.Value /1000
if tick() <= time then
repeat
run.Heartbeat:Wait()
until tick() > time
local notes = rep.Assets.Notes:Clone()
notes.Parent = playerService.LocalPlayer.PlayerGui.BeatsScreen.BeatsFrame
local hitBar = playerService.LocalPlayer.PlayerGui.BeatsScreen.BeatsFrame.HitBar
notes:TweenPosition(UDim2.new(hitBar.Position.X.Scale + 1, hitBar.Position.X.Offset, hitBar.Position.Y.Scale, hitBar.Position.Y.Offset), "Out", "Quad", .9, true)
if audio <= 500 then
print("hold note")
end
end
end
end