Hello, I’m Eli. I’m working on a cutscene plugin, and ran into a problem. Whenever I use httpservice to jsonencode CFrame, it always returns “null”. Is there a way to fix this?
function createplayeradded()
local clone = script.Parent:WaitForChild('Scripts'):WaitForChild("PlayerAdded"):Clone()
clone.Parent = workspace
clone.Disabled = false
clone.Cutscene:WaitForChild('CutsceneKeyframesJSON').Value = game:GetService('HttpService'):JSONEncode(keyframes)
clone.Cutscene:WaitForChild('CutsceneTimesJSON').Value = game:GetService('HttpService'):JSONEncode(keyframetimes)
closesaveoptions()
selected:Set(clone)
wait()
for i = 1,#keyframes do
table.remove(keyframes,i)
table.remove(keyframetimes,i)
end
wait()
keyframesvalue = #keyframes
end
That’s the code I’m trying to fix, and I have no clue how to get started. Any help would be appreciated. Thanks!
function DecodeCFrame(tbl)
return CFrame.new(unpack(tbl))
end
local decoded = game:GetService("HttpService"):JSONDecode(str)
local cfr = DecodeCFrame(decoded)
print(cfr)
You would just use @Jhxan’s code on any CFrame values. There’s no CFrame values in the sample you provided, but if there are children of keyframes and keyframetimes that have CFrame values you’d like to encode, you would need to iterate through the children and store their values in a separate table, using :GetChildren().