ROBLOX Combat System Script - Syntax Error: Expected ')' to close '(' at line 7), got ','
ROBLOX Combat System Script - Syntax Error: Expected ')' to close '(' at line 7), got ','
这是我正在使用的脚本。从这个 YouTube 视频中获得:
https://www.youtube.com/watch?v=jLFegVaNByI.
我已经多次检查并尝试解决这个问题,找不到我的错误。
Roblox Studio PrtScrn:
local RP = game:GetService("ReplicatedStorage")
local Combat = RP:WaitForChild("Combat")
local Animations = script:WaitForChild("Animations")
local anims =
(
Animations:WaitForChild("RightPunch"), -- error is here.
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)
Lua table 是使用 table 构造函数创建的 {}
.
错误信息是由local anims = (Animations:WaitForChild("RightPunch"),
引起的
因为 (expr,
是无效语法。括号内不能有逗号分隔列表 ()
.
而不是预期的 )
Lua 会找到一个 ,
并抱怨它。
但是您一开始就不应该使用 (
,这样错误只是您实际错误的一个征兆。
所以这里的思考过程是:
为什么 Lua 要我在需要 ,
的地方放一个 )
来分隔 table 项?为什么 )
应该在第 7 行关闭 (
?我不需要 (
,这不是你创建 table.
的方式
这是我正在使用的脚本。从这个 YouTube 视频中获得:
https://www.youtube.com/watch?v=jLFegVaNByI.
我已经多次检查并尝试解决这个问题,找不到我的错误。
Roblox Studio PrtScrn:
local RP = game:GetService("ReplicatedStorage")
local Combat = RP:WaitForChild("Combat")
local Animations = script:WaitForChild("Animations")
local anims =
(
Animations:WaitForChild("RightPunch"), -- error is here.
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)
Lua table 是使用 table 构造函数创建的 {}
.
错误信息是由local anims = (Animations:WaitForChild("RightPunch"),
因为 (expr,
是无效语法。括号内不能有逗号分隔列表 ()
.
而不是预期的 )
Lua 会找到一个 ,
并抱怨它。
但是您一开始就不应该使用 (
,这样错误只是您实际错误的一个征兆。
所以这里的思考过程是:
为什么 Lua 要我在需要 ,
的地方放一个 )
来分隔 table 项?为什么 )
应该在第 7 行关闭 (
?我不需要 (
,这不是你创建 table.