如何解决我的代码中的 `'end' expected near '<eof>'` 错误

我该如何解决 'end' expected near '<eof>' 的问题?我尝试了在代码的最后一行和 elseif 中放置 end,但仍然显示这个错误。(顺便说一下,我真的很菜,刚接触 lua)

repeat wait() until game.workspace:FindFirstChild("NPC")
wait(2)
if game.PlaceID == 3541987450 then
print("KHEI")
for i, v in pairs(game.Workspace:GetChildren()) do
    if v.Name == "DevilRoom" then
        if v.BrickColor == BrickColor.new("Dark stone grey") and v.Position ~= Vector3.new(-1283.07092, 1164.82434, -2338.98315, 0.0816411376, -0, -0.996661782, 0, 1, -0, 0.996661782, 0, 0.0816411376) then
game.StarterGui:SetCore("SendNotification", {
    Title = "COLLECTOR";
    Text = "HE SPAWNED" .. "\n" .. "[Plains]";
        Duration = 10000;
})

a = Instance.new("Sound")
a.SoundId = "rbxassetid://39518470341"
a.Parent = game.Lighting
a.Volume = 3
a:Play()

elseif v.BrickColor == BrickColor.new("Bronze") and v.Position ~= Vector3.new(-2604.72559, 1097.82373, 1475.93469, 0.995581567, -0, -0.0939007998, 0, 1, -0, 0.0939007998, 0, 0.995581567) then
    game.StarterGui:SetCore("SendNotification", {
        Title = "COLLECTOR";
        Text = "HE SPAWNED" .. "\n" .. "[Jungle]";
        Duration = 10000;
    })
a = Instance.new("Sound")
a.SoundId = "rbxassetid://3951847031"
a.Parent = game.Lighting
a.Volume = 3
a:Play()
elseif v.BrickColor == BrickColor.new("Fawn brown") and v.Position ~= Vector3.new(-1546.47192, 363.750061, 2445.54663, 0.999748111, 0, 0.0224423129, 0, 1, 0, -0.0224423129, 0, 0.999748111) then
    game.StarterGui:SetCore("SendNotification", {
        Title = "COLLECTOR";
        Text = "HE SPAWNED" .. "\n" .. "[Desert]";
        Duration = 10000;
})
a = Instance.new("Sound")
a.SoundId = "rbxassetid://3951847031"
a.Parent = game.Lighting
a.Volume = 3
a:Play()
点赞
用户113632
用户113632

在 Lua 中,iffor 循环 都需要以 end 结尾。在您的脚本中,需要在适当的位置添加它们;目前看起来您根本没有使用它们。

关于“”的错误消息有点令人困惑;它的意思是“解析器正在寻找一个 end,但到达了文件末尾并没有找到”。_不是_“你需要在文件末尾加上一个 end”。

2020-05-27 21:12:42