I had someone report a bug to me in my game Rhythm Master about how the notes you hold down don’t get updated correctly. Instead of appearing where they’re supposed to, they are drawn as if their position is set to (0, 0, 0, 0). Also, this bug only seems to occur online and not in studio.
Basically, I have some code being run on RunService.RenderStepped (I’ve also tried on regular .Stepped) that’s supposed to reposition the current note you’re holding down. The note is the child of a larger frame that contains all the note gui objects, and this frame is being repositioned before the note is.
The code looks something like this:
(some of the unimportant code was removed)
function SongHandler:TickPlaying(note_frame)
UpdateSongTimer()
note_frame.Position = UDim2.new(-time_to_length_rate * GetSongTimer(), 0, 0, 0)
if current_hold_note then
if GetSongTimer() > current_hold_note:GetPosition() + current_hold_note:GetLength() then
--// hold note has expired so we remove it
current_hold_note = nil
else
--// hold note still has some life so we update it's position for drawing
current_hold_note:UpdateNotePosition(GetSongLength(), GetSongTimer())
end
return
end
--// do updating for missed notes which doesn't happen and isn't important when there is a hold note
return
end
and then the actual function that sets the note GUI’s Position value:
function Note:UpdateNotePosition(tl, p)
local rem_len = note:GetLength() - (p - note:GetPosition())
local s = math.max(0, rem_len / tl)
gui.Size = UDim2.new(s, 0, 1, 0)
gui.Position = UDim2.new(p / tl, 0, 0, 0)
print()
print("p:", p)
print("tl:", tl)
print("p / tl:", p / tl)
print("Position:", gui.Position)
end
When this code runs it works correctly in studio, but it does not online. The value calculated and the value that Position is set to is the correct value for where the note should be drawn at. Both online and in studio I get print output like this:
p: 12.170227893303
tl: 258.204
p / tl: 0.047134157074651
Position: {0.0471341573, 0}, {0, 0}
I haven’t touched this code in probably over a year, and I was just informed that this bug exists today.
If someone working to resolve this wants to look at the game code themselves, the place id is 290276263 and the file with the code is in game.StarterPlayer.StarterPlayerScripts.LocalMain.SongHandler.