我的' elseif'声明有错误

时间:2016-08-14 03:18:45

标签: lua

   if message:sub(6, message:len()) == "%d+" then
        local a = message:find(" ")

        local hatId = message:sub(a + 1, message:len())

        local hat = game:GetService("InsertService"):LoadAsset(tonumber(hatId)):GetChildren()[1]
        hat.Parent = character
        print("Adding hat " .. hatId .. " to " .. player.Name)
    elseif message:sub(6, message:len()) ~= "%d+" then
        local a, b = message:find(" ")
        local c, d = message:find(" ", b + 1)

        local meshId = message:sub(b + 1, d)
        local textureId = message:sub(d + 1, message:len())

        local hat = game:GetService("InsertService"):LoadAsset(tonumber(meshId)):GetChildren()[1]
        hat.Parent = character
        hat.Handle.Mesh.TextureId = "http://www.roblox.com/asset/?id=" .. textureId
        print("Adding hat " .. meshId .. " with texture "  .. textureId .. " to " .. player.Name)
    end

出于某种原因,在我输入/hat hatIdHere后,它会转到elseif语句,并说明local hat = game:GetService(--[===[etc]===]行有错误。

不应该出现错误,因为那里的代码不应该运行。但是,如果我输入/hat meshId textureId,那么它可以正常工作。

请帮助,我不知道为什么这不起作用。我的message是一个已定义的字符串。

0 个答案:

没有答案