Mobile button not detecting that it's no longer being held

I’m trying to make my game mobile compatible, so I’m making buttons for tools, abilities, etc.

Although for some reason on mobile, it’s not detecting that the button is not being pressed anymore after being held.

local function handleAction(actionName, inputState, inputObject)
	if actionName == Pistol and inputState == Enum.UserInputState.Begin and PistolOnCD == false then
		PistolReady()
    elseif actionName == Pistol and inputState == Enum.UserInputState.End and PistolOnCD == false then
		PistolShoot()
    end
end
Tool.Equipped:Connect(function()
	CAS:BindAction(Pistol, handleAction, true, Enum.KeyCode.Z)
end

In the script, when the Z button is held, there’s a debounce that stays true. (while ButtonDown == true do)
When the Z button stops being held, it turns false, and does the rest of the script.

So on PC, it works completely fine, flawless. But on mobile, it just doesn’t turn that debounce to false, which I’m not understanding.
Any help would be appreciated