Hello scripters, I am making a fnf type game, I managed to make a json translator, everything works fine until the moment of starting the round, it turns out that some arrows are delayed or simply do not appear here I leave a video and the script that I use
-- Spawnea una flecha --
local function SpawnArrow(Time, Side, Sustain, Special)
if configGui.Game.MustHitSection.Value == false then
local SpawnTime = (Time)/1000
local SpawnSide
local SpawnPlayer
if not configGui.Game.MustHitSection.Value then
if Side == 0 then
SpawnSide = "Left"
SpawnPlayer = "P1"
elseif Side == 1 then
SpawnSide = "Down"
SpawnPlayer = "P1"
elseif Side == 2 then
SpawnSide = "Up"
SpawnPlayer = "P1"
elseif Side == 3 then
SpawnSide = "Right"
SpawnPlayer = "P1"
elseif Side == 4 then
SpawnSide = "Left"
SpawnPlayer = "P2"
elseif Side == 5 then
SpawnSide = "Down"
SpawnPlayer = "P2"
elseif Side == 6 then
SpawnSide = "Up"
SpawnPlayer = "P2"
elseif Side == 7 then
SpawnSide = "Right"
SpawnPlayer = "P2"
else
warn(Side.. " No es un valor valido para Spawnear alguna Flecha")
end
else
if Side == 0 then
SpawnSide = "Left"
SpawnPlayer = "P2"
elseif Side == 1 then
SpawnSide = "Down"
SpawnPlayer = "P2"
elseif Side == 2 then
SpawnSide = "Up"
SpawnPlayer = "P2"
elseif Side == 3 then
SpawnSide = "Right"
SpawnPlayer = "P2"
elseif Side == 4 then
SpawnSide = "Left"
SpawnPlayer = "P1"
elseif Side == 5 then
SpawnSide = "Down"
SpawnPlayer = "P1"
elseif Side == 6 then
SpawnSide = "Up"
SpawnPlayer = "P1"
elseif Side == 7 then
SpawnSide = "Right"
SpawnPlayer = "P1"
else
warn(Side.. " No es un valor valido para Spawnear alguna Flecha")
end
end
if SpawnPlayer == "P1" then
print("\nExpected " ..tonumber(SpawnTime).. "\nSpawned " .. tonumber(Inst.TimePosition) .. "\n")
local SpawnArrow = Instance.new("ImageLabel")
local arrowMovement = TS:Create(SpawnArrow, TweenInfo.new(1, Enum.EasingStyle.Linear, Enum.EasingDirection.In, 0, false), {Position = UDim2.new(SpawnArrow.Position.X.Scale, 0,-0.25,0)})
SpawnArrow.Name = "Arrow"
SpawnArrow.Size = inGameGui.Game.Player1.BackGround[SpawnSide][SpawnSide.. "_Arrow"].Size
SpawnArrow.Position = UDim2.new(inGameGui.Game.Player1.BackGround[SpawnSide][SpawnSide.. "_Arrow"].Position.X.Scale,0,1,0)
SpawnArrow.Parent = inGameGui.Game.Player1.BackGround[SpawnSide]
SpawnArrow.Image = ("rbxassetid://9582822158")
SpawnArrow.Transparency = 1
SpawnArrow.ImageRectOffset = GetImage(SpawnSide)
SpawnArrow.ImageRectSize = Vector2.new(125, 125)
if Special then
SpawnArrow.ImageColor3 = Color3.new(0, 0, 0)
end
repeat task.wait() until Inst.TimePosition >= SpawnTime
arrowMovement:Play()
arrowMovement.Completed:Connect(function()
SpawnArrow:Destroy()
end)
end
end
end
startRound.OnClientEvent:Connect(function()
local Module = require(songFolder[configGui.ModName.Value].Songs[configGui.SongName.Value].Difficulties[configGui.SongDificulty.Value].Chart)
local chart = HttpsService:JSONDecode(Module)
local BPM = configGui.Game.Bpm
local SPEED = configGui.Game.Speed
local NEEDVOICES = configGui.Game.NeedsVoices
local MUSTHITSECTION = configGui.Game.MustHitSection
BPM.Value = chart.song.bpm
SPEED.Value = chart.song.speed
NEEDVOICES.Value = chart.song.needsVoices
MUSTHITSECTION.Value = false
local sectionTime = tonumber(string.format("%." .. (11) .. "f", (60000/configGui.Game.Bpm.Value) * 4))
local ActualTime = sectionTime
for section, items in pairs(chart.song.notes) do
BPM.Value = items.bpm
MUSTHITSECTION.Value = items.mustHitSection
for notesSection, notes in pairs(items.sectionNotes) do
SpawnArrow(notes[1], notes[2], notes[3], notes[4])
end
repeat task.wait() until Inst.TimePosition >= ActualTime/1000
ActualTime = ActualTime + sectionTime
end
end)
To synchronize the music with the appearance of arrows use “TimePosition”, if anyone has any idea why the arrows are delayed or do not appear I would appreciate it