该脚本不能正常工作。我希望它在我按住 R 键时播放远程控制器

该脚本不能正常工作。我希望它在我按住 R 键时播放远程控制器

local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
mouse.KeyDown:connect(function(key)
  if key == "r" then
    _G.auto = true
    while _G.auto == true do
game:GetService("Players").LocalPlayer.Backpack.Straw.LocalScript.Minus:FireServer()
wait()
end)
end
end
点赞
用户7396148
用户7396148

你的问题似乎是一个放置不正确的 )

当您的代码正确缩进时,问题更容易看出来。

local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
mouse.KeyDown:connect(function(key)
    if key == "r" then
      _G.auto = true
      while _G.auto == true do
        game:GetService("Players").LocalPlayer.Backpack.Straw.LocalScript.Minus:FireServer()
        wait()
      end) -- 这不是 `)` 应该在的地方。
    end
  end -- 这是 `)` 应该在的地方。

你的代码应该在加载时产生一个错误,类似于:

lua:9: unexpected symbol near ')'

这告诉你有一个意外的 ),以及错误所在的行。我不熟悉 Roblox 接口,但我会期望它有一个控制台,在那里错误被输出。

2021-06-23 15:20:09