为什么会一直告诉我使用'wins'索引空值?

我已经设置它通过循环玩家来检查谁是活着的。

local function checkAlive()

    local Player = game.Players:FindFirstChild("leaderstats")
    for i,v in pairs(game.Players:GetChildren()) do
        if v.Character then
            if v.Character.Humanoid.Health > 0 then
                Player.wins.Value = Player.wins.Value + 1
            end
        end
    end

但它一直告诉我使用'wins'索引空值?

点赞
用户16295187
用户16295187
# 检查玩家是否存活

local Player = game:GetService("Players")

local function checkAlive() for i,v in pairs(Player:GetPlayers()) do local leaderstats = v:FindFirstChild("leaderstats") if v.Character then if v.Character.Humanoid.Health > 0 then Player.wins.Value = Player.wins.Value + 1 end end end end

```

以上代码使用 Lua 编写,其目的是检查游戏中所有玩家是否存活,并且统计存活玩家的胜利次数。代码中首先获取了游戏中所有玩家,然后遍历每个玩家,检查其角色是否存活。如果存活,则将 Player.wins.Value 属性的值加 1,以表示这个存活的玩家获得了胜利。

2021-06-23 05:06:25