Lua roblox工作室';结束';预计(在第1行关闭';功能';)在<;eof>;

Lua roblox工作室';结束';预计(在第1行关闭';功能';)在<;eof>;,lua,roblox,Lua,Roblox,我试图编写一些代码,在有人聊天时在工作区内创建一个名为Console的文件夹,当有人说“Console on”时将其删除,但当我在公共游戏中运行它时(因为在roblox studio的测试模式下没有聊天),我得到了标题错误,在阅读了几篇帖子后,都没有答案 game.Players.PlayerAdded:Connect(function(plr) plr.Chatted:Connect(function(msg) print("Connected") if msg == "Console on"

我试图编写一些代码,在有人聊天时在工作区内创建一个名为Console的文件夹,当有人说“Console on”时将其删除,但当我在公共游戏中运行它时(因为在roblox studio的测试模式下没有聊天),我得到了标题错误,在阅读了几篇帖子后,都没有答案

game.Players.PlayerAdded:Connect(function(plr)
plr.Chatted:Connect(function(msg)
print("Connected")
if msg == "Console on" then
    console = Instance.new("Folder",workspace)
    console.name = "Console"
    print("Console Made")
elseif 
    msg == "Console off" then
        print("Console Destroyed")
        console:Destroy()
end
end)

如果代码缩进更加一致,将更容易看到语法错误的位置:

game.Players.PlayerAdded:Connect(function(plr)
    plr.Chatted:Connect(function(msg)
        print("Connected")
        if msg == "Console on" then
            console = Instance.new("Folder",workspace)
            console.name = "Console"
            print("Console Made")
        elseif msg == "Console off" then
            print("Console Destroyed")
            console:Destroy()
        end
    end)
更清楚的是:

game.Players.PlayerAdded:Connect(
    function(plr)
        plr.Chatted:Connect(
            function(msg)
                print("Connected")
                if msg == "Console on" then
                    console = Instance.new("Folder",workspace)
                    console.name = "Console"
                    print("Console Made")
                elseif msg == "Console off" then
                    print("Console Destroyed")
                    console:Destroy()
                end
            end)
您需要在最末端添加另一个
end)
以关闭
游戏。玩家。玩家添加:连接(功能(plr)


如果代码缩进更加一致,将更容易看到语法错误的位置:

game.Players.PlayerAdded:Connect(function(plr)
    plr.Chatted:Connect(function(msg)
        print("Connected")
        if msg == "Console on" then
            console = Instance.new("Folder",workspace)
            console.name = "Console"
            print("Console Made")
        elseif msg == "Console off" then
            print("Console Destroyed")
            console:Destroy()
        end
    end)
更清楚的是:

game.Players.PlayerAdded:Connect(
    function(plr)
        plr.Chatted:Connect(
            function(msg)
                print("Connected")
                if msg == "Console on" then
                    console = Instance.new("Folder",workspace)
                    console.name = "Console"
                    print("Console Made")
                elseif msg == "Console off" then
                    print("Console Destroyed")
                    console:Destroy()
                end
            end)
您需要在最末端添加另一个
end)
以关闭
游戏。玩家。玩家添加:连接(功能(plr)


如果只有两个
end
s,则打开两个函数和一个(else)。如果只有两个
end
s,则打开两个函数和一个(else)。