I want to know how to do this with UserInputService (Enum.KeyCode)
If a player presses a specific E for example it a boolvalue will be true. If the player press it again it's false. How would I do this??
I want to know how to do this with UserInputService (Enum.KeyCode)
If a player presses a specific E for example it a boolvalue will be true. If the player press it again it's false. How would I do this??
Hello,
Here is the script I've made for you:
local UIS = game:GetService("UserInputService") --Declare UserInputService
local boolean = false
UIS.InputBegan:Connect(function(Input) --Declare event
local KeyCode = Input.KeyCode --Declare the "KeyCode" part of the input given
if KeyCode == Enum.KeyCode.E then --Check if the player pressed the letter E (capitals don't matter)
boolean = not boolean --Makes the boolean the opposite of it's value. Ex. makes it false if it is true, and vice-versa.
end
end)
Why did you make a variable for UserInputService if you are only gonna use it once? Seems like a waste of time and memory.
This discussion is preserved as it was. New answers, comments, and votes are closed.
1 comment
wiki.roblox.com/index.php?title=API:Class/UserInputService