-
What do you want to achieve?
So I work on this Friday Night Funkin’ game, which is basically a rhythm game where you have to hit notes, and the problem I am having is that if you are lagging or you end up lagging, the notes will delay and will appear off sync and clumped up, this only happens if you are lagging. I tried changing it using multiple different methods but I’m still unable to fix it. I thought that maybe it could be a problem with the FPS but I’m unsure and don’t know how to change it.
You can check the issue yourself here:
https://www.roblox.com/games/8153555440/FNR-Test-Place
- What is the issue?
As you can see, at first the notes appear properly as I’m not lagging, but as soon as I increase the graphics quality and start lagging the notes start to appear off sync and clumped up.
- What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I tried getting help from a scripter and I looked through the dev forums multiple times but was unable to find anything that could help me with my issue.
This is the code I use to create notes through the client:
coroutine.wrap(function()
repeat task.wait() until stage.Config.TimePast.Value > -4 / speed
--repeat task.wait() until stage.MusicPart.Music.IsPlaying or stage.MusicPart.Vocals.IsPlaying
local notekeys = {}
local notes = basesong.notes or song.notes
local sectionNum = 1
local createNote = Instance.new("BindableEvent"); createNote.Parent = ui.Events
local function makeNote(note, section, notenum)
local timeposition = note[1]
local notetype = note[2]
local notelength = note[3]
local customnote = "normal"
if note[4] then
customnote = note[4]
end
local timeframe = tomilseconds(( time / speed ) / player.Settings.ScrollSpeed.Value)
local timepast = tomilseconds(stage.Config.TimePast.Value)
--//local timepast = Util.tomilseconds(os.clock() - startTime) + offset
local data = timeposition .. "~" .. notetype
if timepast > timeposition - timeframe and not notekeys[data] then
notekeys[data] = true --\\ confirm that nothing is duplicated
local side = section.mustHitSection
local actualnotetype, oppositeSide, hellNote = notetypeconvert(notetype)
if not actualnotetype or not templates:FindFirstChild(actualnotetype) then return end --\\ debugging
if oppositeSide then side = not side end
side = side and "R" or "L"
if not oppositeSide then ui.Side.Value = side end
--\\ add note to game
local slot = templates[actualnotetype]:Clone()
if customnote == "normal" then
slot.Frame.Type.Value = customnote
slot.Frame.Arrow.Visible = true
elseif customnote == nil then
slot.Frame.Arrow.Visible = true
elseif customnote == 1 then
if stage.MusicPart.Vocals.SoundId == "rbxassetid://7520534314" then
slot.Frame.Type.Value = "shoot"
slot.Frame.ShootArrowLeft.Visible = true
end
elseif customnote == 2 then
if stage.MusicPart.Vocals.SoundId == "rbxassetid://7910948478" then
slot.Frame.Type.Value = "slime"
slot.Frame.SlimeArrow.Visible = true
elseif stage.MusicPart.Vocals.SoundId == "rbxassetid://7434809794" or stage.MusicPart.Vocals.SoundId == "rbxassetid://8090496191" or stage.MusicPart.Vocals.SoundId == "rbxassetid://7465895256" or stage.MusicPart.Vocals.SoundId == "rbxassetid://8102995543" or stage.MusicPart.Vocals.SoundId == "rbxassetid://7448220496" or stage.MusicPart.Vocals.SoundId == "rbxassetid://8329456961" then
slot.Frame.Type.Value = "kr"
slot.Frame.KRArrow.Visible = true
elseif stage.MusicPart.Vocals.SoundId == "rbxassetid://7308983181" or stage.MusicPart.Vocals.SoundId == "rbxassetid://8153328371" or stage.MusicPart.Vocals.SoundId == "rbxassetid://8282329705" then
slot.Frame.Type.Value = "static"
slot.Frame.StaticArrow.Visible = true
elseif stage.MusicPart.Vocals.SoundId == "rbxassetid://7520534314" then
slot.Frame.Type.Value = "shoot"
slot.Frame.ShootArrowRight.Visible = true
end
elseif customnote == 3 then
if stage.MusicPart.Vocals.SoundId == "rbxassetid://8085882227" or stage.MusicPart.Vocals.SoundId == "rbxassetid://7434809794" or stage.MusicPart.Vocals.SoundId == "rbxassetid://8090496191" or stage.MusicPart.Vocals.SoundId == "rbxassetid://7465895256" or stage.MusicPart.Vocals.SoundId == "rbxassetid://8102995543" or stage.MusicPart.Vocals.SoundId == "rbxassetid://7448220496" or stage.MusicPart.Vocals.SoundId == "rbxassetid://8329456961" then
slot.Frame.Type.Value = "dust"
slot.Frame.DustArrow.Visible = true
elseif stage.MusicPart.Vocals.SoundId == "rbxassetid://8153328371" then
slot.Frame.Type.Value = "ExePhantom"
slot.Frame.ExePhantomArrow.Visible = true
end
elseif customnote == "sage" then
slot.Frame.Type.Value = customnote
slot.Frame.SageArrow.Visible = true
elseif customnote == "ebola" then
slot.Frame.Type.Value = customnote
slot.Frame.EbolaArrow.Visible = true
elseif customnote == 4 then
else
slot.Frame.Type.Value = customnote
slot.Frame.Arrow.Visible = true
end
if keys == 4 then
slot.Position = UDim2.new(1,0,6.666,0)
else
slot.Position = UDim2.new(1,0,7.666,0)
end
if tonumber(notelength) then
slot.Frame.Bar.Size = UDim2.new(0.325, 0, notelength * (( 0.375 * speed ) * player.Settings.ScrollSpeed.Value ) / 100, 0)
end
slot:SetAttribute("Length", slot.Frame.Bar.Size.Y.Scale)
slot:SetAttribute("Made", tick())
slot:SetAttribute("NoteData", data)
slot.Parent = ui.Game[side].Arrows.IncomingArrows
tweenarrow(slot)
elseif notekeys[data] then
table.remove(notes[sectionNum].sectionNotes, notenum) --\\ removes notes that were already spawned
end
end
createNote.Event:Connect(makeNote)
local noteSpawn; noteSpawn = game["Run Service"].Heartbeat:Connect(function()
local section = notes[sectionNum] or nil --// section used to check for notes
--\\ Debugging
if stage.Config.CleaningUp.Value or not section then noteSpawn:Disconnect() return end
if not section.sectionNotes[1] then sectionNum += 1 return end
--\\ Notes
for notenum, note in pairs(section.sectionNotes) do
createNote:Fire(note, section, notenum)
end
end)
end)()