无法修复脚本

我有一个脚本的问题。我认为与“end”有关,但我真的不知道如何解决它。

点赞
用户10713460
用户10713460

你做错的只是把代码顺序搞错了!哦,还有你需要在结尾加一个括号)。像这样做:

game.Players.PlayerAdded:Connect(function(player)
    if player.Name == 'MateoGaming_YT' then
        player.CharacterAdded:Connect(function(char)
            local trail = game.ServerStorage.Trail:Clone()
            trail.Parent = char.Head
            --还有剩下的拖尾部分
        end)
    end
end)

如果需要更多帮助,请随时问!

2018-12-01 13:57:51
用户2860267
用户2860267

建立在 Vigus Widdicombe-Gasson 的答案基础上,看起来你是在截图你的代码之前纠正了你的脚本。

在“输出”窗口中显示的红色错误告诉你如何找出问题所在。

 ServerScriptService.Script:14: ')' Expected (to close '(' at line 3) near <eof>

这个错误表示,在ServerScriptService中,有一个在第14行抛出错误的脚本。

这个错误是')' Expected near <eof>。这意味着某个地方需要一个闭括号,但是脚本在找到它之前就已经到达了文件的末尾。此外,它告诉我们这个括号的开头在第3行。

所以你需要做的就是在正确的位置添加一个。你的代码缩进使得很难看出错误在哪里,但应该在一个end)语句之后。

为了更清晰地解释,我将在这里重新输入你的代码:

game.Players.PlayerAdded:Connect(function(player)
    if player.name == 'MateoGaming_YT' then
        player.CharacterAdded:Connect(function(char)    -- << 这行需要一个闭括号

            -- 注意如何缩进,尝试在正确的选项卡中保持所有内容
            local attachment0 = Instance.new("Attachement", char.Head)
            local attachment1 = Instance.new("Attachement", char.HumanoidRootPart)
            local trail = game.ServerStorage.Trail:Clone()
            trail.Parent = char.Head
            trail.Attachment0 = attachment0
            trail.Attachment1 = attachment1

        end) -- end player.CharacterAdded
     end -- end if
end) -- end game.Players.PlayerAdded
2018-12-20 21:48:36