UserInputService Script Not Working

I’m trying to make it so that you press 2 buttons, but when I press CTRL, it opens the gui anyway.
Code -

local uip = game:GetService("UserInputService")

	if input.KeyCode == Enum.KeyCode.LeftControl and Enum.KeyCode.R then
		script.Parent.Data.Fix.Visible = true

There is no error, just dosent work. Thanks :smiley:

I don’t believe you can use multiple keycodes for the input object. You should do what was suggested in a similar thread here and use IsKeyDown.

if (input.KeyCode == Enum.KeyCode.LeftControl and UIS:IsKeyDown(Enum.KeyCode.R)) or (input.KeyCode == Enum.KeyCode.R and UIS:IsKeyDown(Enum.KeyCode.LeftControl)) then
1 Like

Is is a Server Script or a LocalScript? The UserInputService only works from the client.

1 Like

You can use multiple inputs, you just need to make sure you’re actually checking both inputs. The way he had it won’t work because he needs to check for the second input.

1 Like

Like what @Stelrex said, you should be checking the second input, like this:

if input.KeyCode == Enum.KeyCode.LeftControl and input.KeyCode = Enum.KeyCode.R then

It’s not tested, but I’m half sure it’ll work.

1 Like

No, @Xx_FROSTBITExX was more on the right track.
Separate UserInputService Events are fired for each key (and each state transition of the key.)
So for instance you could also keep your own CTRL-held flag that you set on InputBegan for the
control key, and then clear it on InputEnded (this is oversimplified, as you should have a timeout, etc.)