Ожидается, что «конец» Roblox Studio (закроет «функцию» в строке 1) около <eof> - PullRequest
0 голосов
/ 28 февраля 2019

Я попытался написать скрипт для создания папки с именем «Консоль» внутри рабочей области, когда кто-то говорил «Консоль включена», и удалить ее, когда кто-то сказал «Консоль выключена», однако, когда я запускаю ее в общедоступной игре (потому что нетчат в тестовом режиме 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)

1 Ответ

0 голосов
/ 01 марта 2019

Если вы сделаете отступ в коде более последовательно, вам будет легче увидеть, где синтаксическая ошибка:

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) в самом конце, чтобы закрыть game.Players.PlayerAdded:Connect(function(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)
    end)
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...