Event fires without manually activating it

Problem


Basically, I’ve been working on a titan shifting system. The player presses P, it triggers an event that is sent to the server and that’s where the titan is created. The problem here is, I’m using ContextActionService, and the event gets fired without the player pressing P. I’m not really sure how to fix it as I’m not that experienced when it comes to ContextActionService.


A piece of the code

local function shifting()
	if not shifted then
		
		shifted = true
		
		titanshift:FireServer(shift)

-- bla bla bla, you don't need to know this.. 
	end
end

local CAS = game:GetService("ContextActionService")

CAS:BindAction("TitanShift", shifting, false, Enum.KeyCode.P)

I am aware that the problem is CAS itself since the function comes first, but I haven’t come up with any solutions, yet. Any help would be appreciated, even a slight push to the solution. Thank you!

local function shifting(actionName, inputState, inputObj)
	if inputState == Enum.UserInputState.Begin then

This did the trick! Credits to this thread for the solution.