Roblox Lua通知开关

我正试图为通知编写一个开关,规则如下:(这是Roblox Lua)

假设我按下“F”,即使我按下“E”或“R”,通知也不会弹出,除非我再次按下“F”,如果我按下“E”或“R”,通知将显示。有什么想法吗?

local KeyBindHigh = "e"
local KeyBindLow = "r"

game.Players.LocalPlayer:GetMouse().KeyDown:Connect(function(Key)
    if Key == KeyBindHigh then
                size = size + change
                game.StarterGui:SetCore("SendNotification", {
                Title = "~ BlackRose ~";
                Text = "达到设置为 " .. size;
                Icon = "";
                Duration = 1;})
        end
    if Key == KeyBindLow then
                size = size - change
                game.StarterGui:SetCore("SendNotification", {
                Title = "~ BlackRose ~";
                Text = "达到设置为 " .. size;
                Icon = "";
                Duration = 1;})
        end
end)

原文链接 https://stackoverflow.com/questions/68977360

点赞
stackoverflow用户15334448
stackoverflow用户15334448
local KeyBindHigh = "e"
local KeyBindLow = "r"

game.Players.LocalPlayer:GetMouse().KeyDown:Connect(function(Key)
    if Key == KeyBindHigh then
        size = size + change
        game.StarterGui:SetCore("SendNotification", {
            Title = "~ BlackRose ~";
            Text = "Reach set to " .. size;
            Icon = "";
            Duration = 1;
        })
    elseif Key == KeyBindLow then
        size = size - change
        game.StarterGui:SetCore("SendNotification", {
            Title = "~ BlackRose ~";
            Text = "Reach set to " .. size;
            Icon = "";
            Duration = 1;
        })
    end
end)

尝试类似这样的方式。这可能是因为你有 if 语句。这应该是有效的。

2021-09-02 18:05:49
stackoverflow用户1296374
stackoverflow用户1296374

如果我理解正确,这是您想要的:

local KeyBindHigh = "e"
local KeyBindLow = "r"
local KeyBindSuspend = "f"

local changeSuspended = false

game.Players.LocalPlayer:GetMouse().KeyDown:Connect(function(Key)
    if Key == KeyBindSuspend then
        changeSuspended = not changeSuspended
        print ("changeSuspended = " .. tostring(changeSuspended))
        return
    end
    if changeSuspended then return end

    if Key == KeyBindHigh then
        size = size + change
        game.StarterGui:SetCore("SendNotification", {
            Title = "~ BlackRose ~";
            Text = "范围设置为 " .. size;
            Icon = "";
            Duration = 1;})
    elseif Key == KeyBindLow then
        size = size - change
        game.StarterGui:SetCore("SendNotification", {
            Title = "~ BlackRose ~";
            Text = "范围设置为 " .. size;
            Icon = "";
            Duration = 1;})
    end
end)
2021-09-02 22:43:51