I have made a menu of keys and it felt empty, so I wanted to add that you can put a primary and a secondary key, the primary one works but the secondary one does not, what do I do?
local Open = false
local keyText = ""
local keyText2 = ""
local MenuKey = game.Players.LocalPlayer:WaitForChild("Keys"):WaitForChild("MenuKey")
local MenuKey2 = game.Players.LocalPlayer:WaitForChild("Keys"):WaitForChild("MenuKey2")
MenuKey:GetPropertyChangedSignal("Value"):Connect(function()
keyText = MenuKey.Value
keyText2 = MenuKey2.Value
end)
local UserInputService = game:GetService("UserInputService")
UserInputService.InputBegan:connect(function(keyCode)
if keyCode.KeyCode.Name == keyText and keyText2 then
if Open then
Open = false
script.Parent.Sombras.Visible = false
else
Open = true
script.Parent.Sombras.Visible = true
end
end
end)
local userInputService = game:GetService('UserInputService')
local myKey1 = 'LeftControl'
local myKey2 = 'H'
userInputService.InputBegan:Connect(function(key, isSystemReserved) -- Ensure you're using :Connect as :connect is deprecated.
if (key.KeyCode.Name == myKey1 and userInputService:IsKeyDown(myKey2)) or (key.KeyCode.Name == myKey2 and userInputService:IsKeyDown(myKey1)) then
print('LeftControl and H are pressed!')
end
end)
Not really, I say it … For example, I have 2 text boxes, one I put in the text “F” and the other one “G”, I want that when pressing the “F”, the script is executed, or that when pressing the “G” also runs
You should be able to use the or operator here. It basically means exactly how it sounds. If the key’s KeyCode is the same as keyText or keyText2 then run.
if (key.KeyCode.Name == keyText) or (key.KeyCode.Name == keyText2) then