for循环失败

我一直在尝试制作一个Roblox剑斗游戏(我的第一个Roblox游戏)。 我在我的代码中发现了一些语法问题,但是修复它们并没有解决这个问题。我一直在检查我的代码,但似乎没有什么用。 这是代码的第15到83行,因为评论告诉我问题出现在for循环之前(前15行只是变量)。

    -- 游戏循环

while true do

    Status.Value = "等待足够的玩家"

    repeat wait(1) until game.Players.NumPlayers >= 2

    Status.Value = "休息时间"

    wait(10)

    local plrs = {}

    for i, player in pairs(game.Players:GetPlayers()) do
        if player then
            table.insert(plrs,player) -- 将每个玩家添加到plrs表中
        end
    end

    wait(2)

    local AvailableMaps = MapsFolder:GetChildren()

    local ChosenMap = AvailableMaps[math.random(1,#AvailableMaps)]

    Status.Value = ChosenMap.Name.."已选择"

    local ClonedMap = ChosenMap:Clone()
    ClonedMap.Parent = workspace

    -- 将玩家传送到地图上

    local SpawnPoints = ClonedMap:FindChild("SpawnPoints")

    if not SpawnPoints then
        print("未找到出生点!")
    end

    local AvailableSpawnPoints = SpawnPoints:GetChildren

    for i, player in pairs(plrs) do
        if player then
            character = player.Character

            if character then
                -- 将他们传送过去

                character:FindFirstChild("HumanoidRootPart").CFrame = AvailableSpawnPoints[1].CFrame + Vector3.new(0,10,0)
                table.remove(AvailableSpawnPoints,1)

                -- 给他们一把剑

                local Sword = ServerStorage.Sword:Clone()
                Sword.Parent = player.Backpack

                local GameTag = Instance.new("BoolValue")
                GameTag.Name = "GameTag"
                GameTag.Parent = player.Character

            else
                -- 没有角色
                if not player then
                    table.remove(plrs,i)
                end
            end
        end
    end

以下是错误信息: 19:30:03.021 - ServerScriptService.Main Script:56: 预期'(', '{'或,得到'for' 帮助我,游戏玩家们

点赞
用户2860267
用户2860267

@luther的评论完全正确。在for循环上面的一行存在语法错误。SpawnPoints:GetChildren是一个函数调用,你忘记添加括号了。

local AvailableSpawnPoints = SpawnPoints:GetChildren()
2020-04-16 20:37:05