ROBLOX 战斗系统脚本-语法错误:在第7行期望使用 ')' 来关闭 '(',但是得到了 ','

这是我使用的脚本,从这个YouTube视频获取:

https://www.youtube.com/watch?v=jLFegVaNByI.

我已经检查了并尝试多次解决此问题,但找不到我的错误。

Roblox Studio PrtScrn:

[! [1](https://i.stack.imgur.com/H4VZy.png)](https://i.stack.imgur.com/H4VZy.png)

local RP = game:GetService("ReplicatedStorage"local Combat = RP:WaitForChild("Combat"local Animations = script:WaitForChild("Animations"local anims =
    (
        Animations:WaitForChild("RightPunch"),--错误在这里。
        Animations:WaitForChild("LeftKnee"),
        Animations:WaitForChild("LeftPunch"),
        Animations:WaitForChild("RightKnee"),
        Animations:WaitForChild("StrongKick"),
    )

Combat.OnServerEvent:Connect(function(player,count)
    local Character = player.Character
    local Humanoid = Character:WaitForChild("Humanoid"local Attack = Humanoid:LoadAnimation(anims [count])
    Attack:Play()

    Combat:FireClient(player)
end)
点赞
用户2858170
用户2858170

Lua 表格使用表格构造器 {} 创建。

错误信息是因为 local anims = (Animations:WaitForChild("RightPunch"), 引起的,

因为 (expr, 是无效语法。你不能在括号 () 内使用逗号分隔的列表。

Lua 会发现一个 , 而不是期望的 ),并向你抱怨。

但是你不应该在第一次使用 (,因此这个错误只是你实际错误的症状。

所以这里的思路是:

为什么 Lua 希望我在需要使用 , 分隔表项的地方放置一个 )?为什么应该在第七行关闭 (?我不需要在那里使用 (,这不是创建表的方法。

2021-01-20 12:51:05