Key press detector not detecting "X" despite it being able to detect "Z" in a different script

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    I want to be able to fire a remote event when you press a button
  2. What is the issue? Include screenshots / videos if possible!

    ^ This stops after if x then return end (i checked with prints)

    ^ this works completely fine
  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    i have looked everywhere, and there isn’t a single thing i could find on it. i even tried switching the detectors with Roblox examples, to no avail.
    After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
    The scripts that receive the fired message are the exact same, except one has a shorter I = x,x loop (shouldn’t effect anything)
    Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.

Try changing if x then return end to if not x then return end.

It didn’t do anything for some reason

Well, I guess you can try printing X before you use that if statement, just to see if the code is even getting to that connection.

when i click X it says true, and repeats false if its not x

Actually it looks like its saying false when i click my mouse
(nvm it detects both im being stupid)

Can I see what your printing in the code? Just to be sure.

I just noticed that the false does not pop up when i hit my x,c, or v keys. i replaced “X” to “G” and it works, why? I mean I can change it but why cant i use the “X”,“C”, and “V” keys when they were literally working yesterday

Are there any scripts in your game using ContextActionService, connecting to the key X?


Last thing. Open the developer console and navigate to this tab. Is one of the keybinds listed Enum.KeyCode.X?


Well, uh. I don’t know why X isn’t working. Try using ContextActionService yourself and see if that works.

local CAS = game:GetService("ContextActionService")

local Mouse = game.Players.LocalPlayer:GetMouse()
local function onpress(_, state, input)
	if state == Enum.UserInputState.Begin then

ContextActionService:BindAction("XPress", onpress, true, Enum.KeyCode.X)

Doesn’t work,

this is how it should look right?

Oh, yes that looks right. I was using visual studio code to script, lol.

Alright, ill just assign the key binds to a different key