【发布时间】:2021-05-15 19:15:37
【问题描述】:
如果调用它的玩家是 JSON 对象中的字符串,我正在制作一个运行另一个模块的模块脚本。
我收到此错误:
Can't parse JSON
-- Stack Begin
-- Script 'Model.MainModule', Line 8 - function load
-- Stack End
代码:
local module = {}
function module.load(plr)
local HttpService = game:GetService("HttpService")
local decoded = HttpService:JSONDecode('{ players: ["HiroTDM999", "mrhotmadm"] }')
for i, v in pairs(decoded.players) do
if v == plr.Name then
require(6380716368).load() -- runs another module (no json in it)
end
end
end
return module
【问题讨论】:
-
@osekmedia 是的,谢谢。
-
大声笑很高兴。
-
是的,哈哈,我现在只需要弄清楚循环。
-
在循环中尝试 ipairs(decoded.players)
-
如果你不使用 i 你可以做类似
for _, v in ipairs(decoded.players) do