:IsKeyDown() not working

I’m working on a VR project, and I need to check if the triggers/grips are pressed. I’m using the line of code below but it constantly prints false :<

	print(game:GetService("UserInputService"):IsKeyDown(Enum.KeyCode.ButtonL1))

I also tried using InputBegan and InputEnded to set a boolean but when I hold grip it only turns to true for one frame then back to false

Could you give the code that you use for the script?

Also make sure that you are using UserInputService in a local script.

I would also recommend using InputBegan and InputEnded so you don’t have to use IsKeyDown in a loop to check.

VR is a Controller, so it Requires :arrow_down:

:IsGamepadButtonDown()

When using Controllers, it checks to see what Controller Pressed the Button with UserInputType. As you could have more than one Controller connected(it goes up to 8 Controllers).
So the complete Code would be :arrow_down:

UserInputService:IsGamepadButtonDown(Enum.UserInputType.Gamepad1,Enum.KeyCode.ButtonL1)

Figured it out, I was resetting the variables to false somewhere in the script (idk why xD). Working now!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.