【发布时间】:2021-02-18 09:22:35
【问题描述】:
所以我试图保存 3 件东西,但即使在打印值时它有效,它也无法在保存脚本中索引它们:
game.Players.PlayerRemoving:Connect(function(player)
local stats = player:FindFirstChild(ns0)
if not stats then return end
local vals = {stats:FindFirstChild(nc0),stats:FindFirstChild(nc1),stats:FindFirstChild(nc2)}
print(vals) -- returns: {...}
print(vals[1], vals[2], vals[3]) -- returns: Cash NumberValue dropspeed
print(vals[1].Value, vals[2].Value, vals[3].Value) -- returns: 0.1 0.02 9.5
print(player.UserId) -- returns my user Id
--if vals and vals[1] and vals[2] and vals[3] then
if vals[1] and vals[2] and vals[3] then
ds:SetAsync(player.UserId,{vals[0].Value, vals[1].Value, vals[2].Value}) -- attempt to index nil with Value error occurs here
end
end)
有什么问题?
【问题讨论】:
-
vals[0]是nil。