【问题标题】:Roblox game auto detectorRoblox 游戏自动检测器
【发布时间】:2021-05-25 02:35:22
【问题描述】:

好的,所以我正在制作一个 gui,它会自动检测你在玩什么游戏。唯一的问题是,如果你在游戏中它不支持它应该踢你并留言

if game.GameId == "301549746" then
    btxt.Text = "Game detected, Counter-Blox"
end
if game.GameId == "137877687" then
    btxt.Text = "Game detected, Rociticens"
end
if game.GameId == "286090429" then
    btxt.Text = "Game detected, Aresenal"
end

if else 
    game.Players.LocalPlayer:Kick("game not supported");
end 

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

【问题讨论】:

  • 我看不懂这句话“我不能在这段代码中做其他事情,因为它有错误”,你是说代码有运行时错误??
  • 我的意思是我不能在那种情况下使用 else 我不知道为什么,它只是用红色强调“else”然后根本不会运行

标签: lua roblox


【解决方案1】:

您应该使用 elseif,因此该语句只运行一次,并且 else 关键字必须放在语句结束之前

在编写嵌套 if 时,可以使用 elseif。它类似于 else 后跟 if,但它避免了多端的需要:

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

【讨论】:

  • 是的,尽管我尝试了 elseif,但仍然会出错,否则会出错。一切都好
  • @Chrons,看看 PONGPONG 链接上的代码示例。你的代码结构是这样的:if <condition> then ... elseif <condition> then ... else ... end
猜你喜欢
  • 2021-06-09
  • 2010-09-06
  • 1970-01-01
  • 1970-01-01
  • 2021-03-25
  • 2020-09-13
  • 2020-12-17
  • 1970-01-01
  • 2021-10-09
相关资源
最近更新 更多