TouchTapInWorld event does not fire immediately sometimes?

Hi all,

Sometimes I test my game, and the TouchTapInWorld event does not fire even if I’m tapping until I’m in the game for a few minutes. Sometimes, I don’t get this error, and I’m able to shoot the bullet normally. I’m not sure why this is the case, but I suspect it may have something to do with the fact that there is a userinputservice before it? I know it has something to do with userinputservice because the print statement within the TouchTapInWorld does not fire; however, I don’t know what could be causing this issue.

UserInputService.InputBegan:Connect(function (input, gameHandledEvent)
	if gameHandledEvent or not ExpectingInput then
		return
	end
	
	if input.UserInputType == Enum.UserInputType.MouseButton1 and Mouse ~= nil then
		local FireDirection = CFrame.new(GunFirePoint.WorldPosition, Mouse.Hit.p)
		Fire(FireDirection)
	end
end)

UserInputService.TouchTapInWorld:Connect(function (position, processedByUI)
	print("Tap")
	if processedByUI or not ExpectingInput then
		return 
	end
	
	local UnitRay = workspace.CurrentCamera:ViewportPointToRay(position.X, position.Y)
	local NewRay = Ray.new(UnitRay.Origin, UnitRay.Direction * 500)
	local hit, worldPosition = workspace:FindPartOnRay(NewRay)
	local FireDirection = CFrame.new(GunFirePoint.WorldPosition, worldPosition)
	Fire(FireDirection)
end)

Would you please show us the output from your script.
Can you include prints of any variable set before the script runs.