Hello devs, sooo I am working on FNF game and I was trying to use FNF’s json charts, and this is my current code :
local time = 1.75
local basesong = game:GetService("HttpService"):JSONDecode(script.Parent.music.Chart.Value)
local song = basesong.song
local notes = song.notes
for i,x in pairs(song) do
print("[" .. tostring(i) .. "] = " .. tostring(x))
end
local notekeys = {}
local notes = basesong.notes or song.notes
print(notes.sectionNotes)
local function tomilseconds(seconds)
return seconds*1000
end
local function toseconds(milliseconds)
return milliseconds/1000
end
local function notetypeconvert(type)
if tonumber(type) then
if type == 0 then return "Left" end
if type == 1 then return "Down" end
if type == 2 then return "Up" end
if type == 3 then return "Right" end
if type > 3 then
return notetypeconvert(type-4), true
end
end
end
local function note(typ, speed)
if typ == "Left" then
local note = game.ReplicatedStorage.Notes.LeftNote:Clone()
note.Parent = script.Parent.Left
note.Position = UDim2.new(script.Parent.Left.Left.Position.X.Scale, 0,6, 0)
note:TweenPosition(UDim2.new(script.Parent.Left.Left.Position.X.Scale, 0,-6, 0), Enum.EasingDirection.Out, Enum.EasingStyle.Linear, speed)
coroutine.wrap(function()
task.wait(speed)
note:Destroy()
end)()
elseif typ == "Down" then
local note = game.ReplicatedStorage.Notes.DownNote:Clone()
note.Parent = script.Parent.Left
note.Position = UDim2.new(script.Parent.Left.Down.Position.X.Scale, 0,6, 0)
note:TweenPosition(UDim2.new(script.Parent.Left.Down.Position.X.Scale, 0,-6, 0), Enum.EasingDirection.Out, Enum.EasingStyle.Linear, speed)
coroutine.wrap(function()
task.wait(speed)
note:Destroy()
end)()
elseif typ == "Up" then
local note = game.ReplicatedStorage.Notes.UpNote:Clone()
note.Parent = script.Parent.Left
note.Position = UDim2.new(script.Parent.Left.Up.Position.X.Scale, 0,6, 0)
note:TweenPosition(UDim2.new(script.Parent.Left.Up.Position.X.Scale, 0,-6, 0), Enum.EasingDirection.Out, Enum.EasingStyle.Linear, speed)
coroutine.wrap(function()
task.wait(speed)
note:Destroy()
end)()
elseif typ == "Right" then
local note = game.ReplicatedStorage.Notes.RightNote:Clone()
note.Parent = script.Parent.Left
note.Position = UDim2.new(script.Parent.Left.Right.Position.X.Scale, 0,6, 0)
note:TweenPosition(UDim2.new(script.Parent.Left.Right.Position.X.Scale, 0,-6, 0), Enum.EasingDirection.Out, Enum.EasingStyle.Linear, speed)
coroutine.wrap(function()
task.wait(speed)
note:Destroy()
end)()
end
end
script.Parent.music:Play()
task.spawn(function()
while task.wait() do
for sectionnum, section in pairs(notes) do
for notenum, note in pairs(section.sectionNotes) do
print(note)
local timeposition = note[1]
local notetype = note[2]
local notelength = note[3]
local timeframe = tomilseconds(time / song.speed)
local timepast = tomilseconds(1)
local data = timeposition .. "~" .. notetype
if not notekeys[data] and timepast > timeposition - timeframe then
--table.remove(notes[sectionnum]["sectionNotes"], notenum)
notekeys[data] = true
local side = section.mustHitSection
--\\ Delete note from table
table.remove(section.sectionNotes, notenum)
--\\ Add note to game
if notetype ~= nil and tonumber(notetype) then
note(tonumber(notetype), song.speed)
else
note(math.random(1,4), song.speed)
end
end
end
end
end
end)
task.spawn(function()
while task.wait() do
if script.Parent.music.PlaybackLoudness > 1.5 then
local beat = game:GetService("TweenService"):Create(script.Parent.Left.UIScale, TweenInfo.new(0.2,Enum.EasingStyle.Cubic, Enum.EasingDirection.InOut, 0, false, 0), {
Scale = 1;
})
script.Parent.Left.UIScale.Scale = 1.02
beat:Play()
beat.Completed:Wait()
end
end
end)
But it shows this error :
Players.JaceMorphing.PlayerGui.ScreenGui.LocalScript:101: attempt to call a table value
Why doesn’t it work?