0
votes

im trying to make a toggle for the notifications with the following rules: (THIS IS ROBLOX LUA BY THE WAY)

let's say if i press "f" even if i press "e" or "r" the notification wont pop up, unless i press "f" again, and then if i press "e" or "r" the notification will show. any ideas?

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;})
        end
    if Key == KeyBindLow then 
                size = size - change
                game.StarterGui:SetCore("SendNotification", {
                Title = "~ BlackRose ~";
                Text = "Reach set to " .. size;
                Icon = "";
                Duration = 1;})
        end
end)
2

2 Answers

0
votes
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)

Try something like this. It could be because you have the if statements. This should work.

0
votes

If I understand you correctly, this is what you want:

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 = "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)