Roblox 游戏自动检测器

好的,我正在制作一个 GUI,它可以自动检测你所在的游戏... 唯一的问题是,如果你在一个它不支持的游戏中,它应该会踢你并留下一条消息

if game.GameId == "301549746" then
    btxt.Text = "检测到游戏,反恐精英"
end
if game.GameId == "137877687" then
    btxt.Text = "检测到游戏,城民"
end
if game.GameId == "286090429" then
    btxt.Text = "检测到游戏,Arsenal"
end

if else
    game.Players.LocalPlayer:Kick("游戏不支持");
end

出于某种原因,在这种情况下我不能使用 else 它只是会用红色下划线标出“else”,然后不运行

点赞
用户15220619
用户15220619

当你在编写嵌套的 if 语句时,你应该使用 elseif,因为它类似于一个 else 加上一个 if,但是避免了需要使用多个 end:

https://www.lua.org/pil/4.3.1.html

2021-02-22 20:17:03